This article describes how cookies work and ways cookies can be used for your benefit, as a webmaster, without compromising your visitor's privacy.
If you're an experienced programmer (or brave :-), you can go directly to Netscape.com's preliminary cookie specifications page. Otherwise, use it as a reference after you have more understanding about cookies and how you want to use them. The page is at http://home.netscape.com/newsref/std/cookie_spec.html
Cookies are benign text data records stored on your visitor's hard drive. According to the specifications, the only internet site able to retrieve a cookie from that hard drive is the site that put it there in the first place.
Cookies are not programs. They are plain text data.
Cookies can not gather information on their own. The data cookies contain has been gathered by other means. And cookies can not collect personal information about your visitors from their computer.
Cookies allow your site to store information on your visitor's computer for later retrieval.
When your visitors surf your site, they go from page to page. Ideally, it is a smooth, continuous experience.
For your server it is not that way. During the time between when one of your visitors arrives at pageD.html and decides to click to pageR.html, there may have been dozens of other visitor browsers retrieving those same and other pages. Once your server delivers a page to a browser, it disconnects from the browser.
There is no automatic method of remembering information from one page to the next.
In many situations, using cookies is the most efficient method of remembering and tracking preferences, purchases, commissions, and other information required for better visitor experience or site statistics.
How It Works:
Your server sends some data to the visitor's browser in the form of a cookie. (The exact format will be discussed later.) The data is plain text.
The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive.
Now, when the visitor arrives at another page on your site, the cookie is available for retrieval. Once retrieved, your server knows/remembers what was stored.
Cookies have specific size limits:
1. A cookie may be no larger than 4k.
2. There may be no more than 20 cookies per domain.
3. There may be no more than 300 cookies total from all sources.
(Note that browsers are not required to conform to those limits. They may allow more or larger cookies. However, responsible programming requires respect for the specifications.)
If your server asks a browser for cookies it may have accepted while at your site and none are available, either
~~ the visitor has never been at your site,
~~ the browser did not accept cookies your server offered,
~~ in order to stay within the 300 cookie limit, the browser deleted your domain's cookie(s) from the hard drive when accepting cookies from other sites, or
~~ the visitor manually deleted your server's cookie(s) from the hard drive.
Continue: Page 
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Web Development Articles
More By Developer Shed