HTML and CSS Reference
In-Depth Information
a ppendix G
Working with
Cookies
Introducing Cookies
A cookie is a piece of information stored in a text file that a Web
browser places on a user's computer. Typically, cookies contain data
to be accessed the next time a user visits a particular Web site. For
example, many online stores use cookies to store users' addresses
and credit card information. This enables a store to access previ-
ously entered information from a cookie the next time a repeat user
makes a purchase, freeing the user from reentering this material.
Where a browser places a cookie file depends on the browser.
Firefox, Google Chrome, Safari, and Opera save all of their cookies
within a single file stored in a user profile folder associated with each
application. Internet Explorer stores cookies in a single text file named
cookie.txt . Browsers limit each cookie to 4 kilobytes in size, and a
computer can generally not store more than 300 cookies at one time. If
a browser tries to store more than 300 cookies, the oldest cookies are
deleted to make room. Finally, most browsers allow for 20 cookies per
Web site domain.
Cookies, the Web Server, and
CGI Scripts
The first implementation of cookies was with a CGI script running
on a Web server. A CGI script can retrieve the cookie information
and perform some action based on the information in the file. The
process works as follows:
1. A user accesses the Web site and sends a request to the CGI
script on the Web server, either by filling out an order form or
by some other process that calls the CGI script.
2. The CGI script determines whether a cookie for the
user exists.
3. If no cookie is detected, the Web server sends a form, or page,
for a user to enter the information needed by the cookie. This
information is then sent to the CGI script for processing.
4. If a cookie is found, the CGI script retrieves that information
and creates a new page, or modifies the current page, based on
the information contained in the cookie.
Starting data FileS
There are no starting Data Files needed for this appendix.
HTML G1
 
Search WWH ::




Custom Search