A magic cookie, or just cookie for short, is a token or short packet of data passed between communicating programs, where the data is typically not meaningful to the recipient program. The contents are opaque and not usually interpreted until the recipient passes the cookie data back to the sender or perhaps another program at a later time. The cookie is often used like a ticket – to identify a particular event or transaction.
In some cases, recipient programs are able to meaningfully compare two cookies for equality.
- "ftell returns the current value of the ofset relative to the beginning of the file associated with the named stream. It is measured in bytes on UNIX; on some other systems it is a magic cookie, and the only foolproof way to obtain an offset for fseek."
Cookie as token
An analogy is the token supplied at a coat check (cloakroom) counter in real life. The token has no intrinsic meaning, but its uniqueness allows it to be exchanged for the correct coat when returned to the coat check counter. The coat check token is opaque because the way in which the counter staff are able to find the correct coat when the token is presented is immaterial to the person who wishes their coat returned. In other cases (as is possible with HTTP cookies), the actual data of interest can be stored as name–value pairs directly on the cookie.
Cookies are used as identifying tokens in many computer applications. When one visits a website, the remote server may leave an HTTP cookie on one's computer, where they are often used to authenticate identity upon returning to the website.
- Raymond, Eric. "Cookie". The Jargon File. Retrieved 2014-02-03.
- UNIX Programmer's Manual, 7th Edition, Vol. 1, FSEEK (3S), Bell Telephone Laboratories, Murray Hill, New Jersey, January 1979.
- UNIX Programmer's Manual, Vol. II (Library), FSEEK (3S), 4.2 BSD, 12 Feb 1983.
- "Distributed Erlang". erlang.org. Retrieved 2014-02-03.
- "RFC 6265 - HTTP State Management Mechanism". Tools.ietf.org. Retrieved 2014-02-03.
- "Xsecurity". X.org. Retrieved 2014-02-03.