1

I have 2 cookies in my index page which comes from a user prompt. The cookies are "user=userinput" and "pass=userinput". How would I call these cookies to be able to edit DOM HTML?

The code I have setting the cookies is basic document.cookie = "user=Jeff; path=/pages/" and document.cookie = 'pass='+passToCheck+'; path=/pages'.

So how do I call document.cookie["user="] or document.cookie["pass="], is this possible?

  • 1
    Does this answer your question? [Set cookie and get cookie with JavaScript](https://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript) – Dmitry S. May 07 '20 at 21:58
  • `document.cookie` returns a string, not an object. You simply parse that string into an array by splitting it at the semicolon and then access the array items. – Scott Marcus May 07 '20 at 21:58

0 Answers0