What is a cookie?
Cookies are one of the most widely used, misused, and misunderstood features of the Web. Their basic function is simple: allow Web servers to store and retrieve information on the client-side (or within your web browser). Although cookies can make the Web surfing experience more personalized and streamlined, many users regard them with suspicion because of concerns about privacy.
When used appropriately, cookies can be an invaluable tool for a webmaster. You can use them to simplify sign-on procedures, set up shopping carts, and provide individual users with more personalized information on your site. Site visitors are becoming increasingly discriminating: they demand useful content presented quickly and clearly.
Cookies can help you incorporate those features into your site.
What Cookies Are - And Are NOT
First, you must understand what cookies are:
- A cookie is a unique bit of information sent by a Web server to identify a particular machine and browser.
- Cookies are stored in a text file whose exact name and location depend on the user's operating system and browser
- Username and password
- Date of last visit
Even more important, understand what cookies are NOT:
- Cookies cannot store any personal information about the user that the user doesn't voluntarily supply to the Web site.
- Cookies do not contain viruses.
- A server can only get data from the cookie it wrote to the cookie file - it can't go fishing for information on the hard drive.
A good example of a simple cookie is on the Amazon.com Web site. Registered users see a personalized message when they visit:
"Hello, John Smith, we have recommendations for you in books, music, and video."
Links take the user to a personalized page that highlights products based on their personal profile.
Useful Applications For Cookies
Web sites use cookies for a number of different reasons. Some of the most common include:
Site Personalization - As in the Amazon example above, you can use cookies to identify visitors and direct them to areas of you site that might interest them most.
This can be as simple as flagging new stories or products added to the site since their last visit or as complicated as rendering pages that are almost completely customized based on stored preferences (favorite music, nonfiction categories, etc).
Online Ordering - Many e-commerce sites use cookies to track additions or deletions to your shopping cart. Sites can use session cookies that are valid only for the duration of that particular visit, or design them so that the user can return to the site days later and complete their transaction.
Web site Tracking - Cookies provide you with a more accurate count of site visitors. Using cookies, you can insure that someone who visits your site 3 times per day isn't counted as a unique user each time. You can also see how often repeat visitors visit and what items they view most often (very helpful if you want to personalize a site).