Magic cookie
   HOME

TheInfoList



OR:

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 * Progra ...
. The cookie is often used to identify a particular
event Event may refer to: Gatherings of people * Ceremony, an event of ritual significance, performed on a special occasion * Convention (meeting), a gathering of individuals engaged in some common interest * Event management, the organization of ev ...
or as "handle, transaction ID, or other token of agreement between cooperating programs". The term derives from the
fortune cookie A fortune cookie is a crisp and sugary cookie wafer usually made from flour, sugar, vanilla, and sesame seed oil with a piece of paper inside, a "fortune", usually an aphorism, or a vague prophecy. The message inside may also include a Chine ...
, which is a cookie with an embedded message.


Usage

Cookie data is typically not meaningful to the recipient program. The contents are
opaque Opacity or opaque may refer to: * Impediments to (especially, visible) light: ** Opacities, absorption coefficients ** Opacity (optics), property or degree of blocking the transmission of light * Metaphors derived from literal optics: ** In lingui ...
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 A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and e ...
for the fseek 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 A cloakroom, or sometimes coatroom, is a room for people to hang their coats, cloaks or other outerwear when they enter a building. Cloakrooms are typically found inside large buildings, such as gymnasiums, schools, churches or meeting halls. ...
) counter in
real life Real life is a phrase used originally in literature to distinguish between the real world and fictional, virtual or idealized worlds, and in acting to distinguish between actors and the characters they portray. It has become a popular term on the ...
. 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 W ...
, the remote server may leave an HTTP cookie on one's computer, where they are often used to
authenticate Authentication (from ''authentikos'', "real, genuine", from αὐθέντης ''authentes'', "author") is the act of proving an assertion, such as the identity of a computer system user. In contrast with identification, the act of indicatin ...
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 wi ...
.


References

{{Authority control Data transmission pl:Cookie