Name
cookie — NN 2 IE 3 DOM 1
Synopsis
Read/Write
The HTTP cookie associated with the domain of the document and stored
on the client machine in the “cookie file.” Reading and
writing the cookie
property are not parallel
operations. Reading a cookie
property returns a
semicolon-delimited list of name/value pairs in the following format:
name=value
Up to 20 of these pairs can be stored in the cookie property for a
given domain (regardless of the number of HTML documents used in that
web site). A total of 4,000 characters can be stored in the cookie,
but it is advisable to keep each name/value pair to less than 2,000
characters in length. It is up to your scripting code to parse the
cookie
property value for an individually named
cookie’s value.
Writing cookie
property values allows more
optional pairs of data associated with a single name/value pair. The
format is as follows:
document.cookie = "name
=value
[; expires=timeInGMT
] [; path=pathName
] [; domain=domainName
] [; secure]"
No matter how many optional subproperties you set per cookie, only
the name/value pair may be retrieved. All cookie data written to the
cookie
property is maintained in the
browser’s memory until the browser quits. If an expiration date
has been made part of the cookie data and that time has not yet
expired, the cookie data is saved to the actual cookie file;
otherwise, the cookie data is discarded. The browser automatically
deletes cookie data that has expired when the browser next starts.
Example
var exp = new ...
Get Dynamic HTML: The Definitive Reference 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.