In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, a magic cookie, or just cookie for short, is a token or short packet of data passed between communicating
programs
Program, programme, programmer, or programming may refer to:
Business and management
* Program management, the process of managing several related projects
* Time management
* Program, a part of planning
Arts and entertainment Audio
* Programm ...
. The cookie is often used to identify a particular
event or as "handle, transaction ID, or other token of agreement between cooperating programs". The term derives from the
fortune cookie, which is a cookie with an embedded message.
Usage
Cookie 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.
In some cases, recipient programs are able to meaningfully compare two cookies for equality.
The cookie can be used like a
ticket.
Early use
The term ''magic cookie'' appears in the
man page for the
fseek
The C programming language provides many standard library functions for file input and output. These functions make up the bulk of the C standard library header . The functionality descends from a "portable I/O package" written by Mike Lesk ...
routine in the C standard library, dating back at least to 1979, where it was stated:
* "''ftell'' returns the current value of the offset 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''."
[Bell Telephone Laboratories, Incorporated. "FSEEK(3S)." In ''UNIX Time-Sharing System: UNIX Programmer’s Manual'', Revised and expanded version of 7th Edition, Volume 1, page 263. New York: Holt, Rinehart and Winston, 1983. https://archive.org/details/unixtimesharings0001bell]
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 cookie
HTTP cookies (also called web cookies, Internet cookies, browser cookies, or simply cookies) are small blocks of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user's ...
s), 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
A website (also written as a web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. Examples of notable websites are Google, Facebook, Amazon, and Wikip ...
, 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.
Cookies are a component of the most common authentication method used by the
X Window System
The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems.
X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting ...
.
References
{{Authority control
Data transmission
pl:Cookie