HTML and CSS Reference
In-Depth Information
chapter
16
Cookies
16.1 What Are Cookies?
The Web protocol, HTTP, was designed to be stateless to keep transactions between a
browser and server brief and cut down on the overhead of keeping connections open.
Stateless means that after a transaction takes place between the browser and server, the
connection is lost and neither the browser nor server have any recollection of what
transpired between one session and the next. But as the Internet grew and people started
filling up shopping carts with all kinds of goodies, ordering everything from groceries
to music, books, prescription drugs, and even cars and homes, it became necessary for
merchants to remember what their customers purchased, their preferences, registration
numbers, user IDs, and so on. Enter Netscape way back in 1994 with the cookie. A
cookie is a local file used to store information, and it is persistent; that is, it is maintained
between browser sessions and remains even when the user shuts down his or her com-
puter. The cookie idea became very popular and is now supported by all major browsers.
The term “cookie” comes from an old programming trick for debugging and testing
routines in a program. A text file called a “magic cookie” was created. It contained text
that was shared by two routines so that they could communicate with each other. The
cookie feature started by Netscape 1 is also just a little piece of textual data that is stored
in a file (often called the cookie jar) on the hard drive of the client (browser). It contains
information about the viewer as he or she navigates different pages on a Web site or
returns to the Web site at a later time. The information might be as simple as to welcome
the viewer to your site, and based on past visits, show him or her a new book by a favor-
ite author, display the latest stock quotes, or take the user to CNN Europe when he or
she wants to view the news. It could save billing and shipping information to be
retrieved at a later time to save retyping it over again.
There are two kinds of cookies: session cookies and persistent cookies. The session
cookies are stored in memory on the server, whereas persistent cookies are stored in a
1. See www.netscape.com/newsref/std/cookie_spec.html for cookie specification.
695
 
 
 
Search WWH ::




Custom Search