Cookies
Description
A cookie is a small piece of data stored by a web browser at the request of a web site, for the purpose of conveying state between related web page requests. Common uses of cookies include:
- session tracking;
- authentication;
- recording user preferences; and
- web analytics.
Cookies held by the browser can be accessed by the server using the HTTP Cookie
and Set-Cookie
headers. For CGI scripts they are passed in the environment variable HTTP_COOKIE
. Cookies are also accessible to code running locally on the web browser if a suitable API has been provided for the language in question. Examples include document.cookie
for JavaScript, and that in combination with netscape.javascript.JSObject
for Java applets.
microHOWTOs
- Create a cookie in JavaScript
- Delete a cookie in JavaScript
- Inspect the value of a cookie in JavaScript
See also
Further Reading
- A. Barth, HTTP State Management Mechanism, RFC 6265, IETF, April 2011
- Persistent Client State HTTP Cookies, Netscape (historical specification)
- Cookies, QuirksMode