A cookie allows a website to store "state" information on your computer. This information allows for a website to remember what "state" your browser is in. An ID is one simple piece of state information. If an ID exists on your computer, the website knows that you have visited before. The "state" is - Your browser has visited the website at least one time and the website knows your ID from that visit.
- Websites can accurately determine how many people actually visit the site. It turns out the only way for a website to accurately count visitors is to set a cookie with a unique ID for each visitor. Using cookies, sites can determine:
- How many visitors
- New visitors vs. repeat visitors
- How often a visitor has viewed the website
Websites use a data base. The first time a visitor arrives, the website creates a new ID in the database and sends the ID as a cookie to the visitor's computer to be stored. The next time the user comes back, the website can increment a counter associated with that ID in the database and know how many times that visitor has been there.
- Websites can also store user preferences so that the site can look different for each visitor. For example, if you visit yahoo.com, it offers you the ability to change the content/layout/color of the homepage. It also allows you to enter your zip code and get customized weather information.
- E-commerce websites can implement things such as shopping carts and checkout options. The cookie contains an ID and lets the website keep track of you as you add items into your cart. Each item you add is stored in the site's database along with your ID. When you check out, the site knows what is in your cart by retrieving all of your selections from the database. It would be impossible to implement a shopping mechanism without cookie technology.