cookie.js defines the following functions:
deleteCookie()deleteCookie(name, path, domain)
nameThe name of the cookie to be deleted.
pathAn optional path for the cookie. This value must match the path used to set the original cookie in order to erase the cookie. If this argument is omitted, a value of '/' will be used.
domainAn optional root domain for the cookie. This value must match the domain used to set the original cookie in order to erase the cookie. If this argument is omitted, the host name of the current server will be used.
The value previously contained in the deleted cookie. If the cookie couldn't be found, null will be returned.
deleteCookie() immediately deletes the named cookie that matches the path and domain information.
fixDate()fixDate(date)
dateThe date to be corrected. This should be a Date object.
A reference to a Date object that represents the correct date.
fixDate() was intended to work around a bug in some Netscape 2 browsers where all Date objects were incorrect by a day. This function would create and return a correct date for any Date object. It will not break dates on any other browsers. It is included for cases when support of ancient browsers is required.
getCookie()getCookie(name)
nameThe name of the cookie to retrieve the value of.
The value associated with the named cookie. If the cookie doesn't exist, the function returns null.
getCookie() retrieves the value of a previously created cookie.
setCookie()setCookie(name, value, expires, path, domain, secure)
nameThe name of the cookie. All cookies from the same domain must have unique names. The name can not contain semi-colons, commas or any whitespace (such as tabs or spaces).
valueThe value to be stored with the name.
expiresAn optional expiry date. This should be a Date object that specifies when the cookie should be deleted by the system. Dates in the past will erase the cookie. If this argument is omitted, the cookie will last for the rest of the browser session (it will be erased when the browser is closed).
pathAn optional path from which the cookie will be visible. This should be a valid path that starts with a '/'. For instance, a path of '/foo' will allow the urls /foo/index.html and /foo/bar/index.html to see the cookie but not /index.html. If this argument is omitted, the cookie will be visible to all pages in the originating domain.
domainAn optional root domain from which the cookie will be visible. For instance, a domain of store.acme.com will allow servers at anvil.store.acme.com and rocket.store.acme.com to see the cookie but not www.acme.com. If this argument is omitted, the host name of the originating domain is used.
secureAn optional flag to indicate if the cookie should be sent over secure connections. If a value of true is used, the cookie will only be sent over secure (https) connections. If a value of false is used, the cookie should be available over both secure and unsecure connections (Netscape, however, will not let such a cookie be visible over secure connections). If this argument is omitted, then the cookie will be unsecure.
Nothing.
setCookie() associates the value with the name and creates a cookie. If an expiry date is provided, the cookie will become persistent and will be stored by the visitor's computer until that date. Cookies without expiry dates are session cookies and will be erased when the visitor closes their browser. In order to give a new value to an existing cookie, use setCookie() with the same values for the name, path, domain, and secure arguments as was used when creating the original cookie.
supportsCookies()supportsCookies(rootPath)
rootPathAn optional path for the test cookie so that only one will be created if you test on multiple pages with different paths. Use '/' if you control the whole domain. If your site root is www.some-domain.com/~me/, use '/~me/'. If no path is provided, the test cookie will use the path of the HTML document.
true if cookies are supported, false otherwise.
supportsCookies() determines if a browser supports cookies and has turned on cookie support. It's a good idea to call this function before relying on cookies to store state information.