24.7. Using JavaScript to Store and Examine Cookies
A cookie is a small amount of textual information about a page that is stored by the browser on the client system. A cookie can also be manipulated entirely on the client through the use of the document.cookie property. This property behaves in a very unusual fashion. If you look up the value of document.cookie, you will get a single big string containing all the cookie values, as sent by the browser through the Cookie HTTP request header. For example, if the current page has three cookies name1, name2, and name3, the value of document.cookie would be something like
"name1=val1; name2=val2; name3=val3"
However, you do not assign values to document.cookie by using a single large string like ...
Get Core Web Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.