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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.