Cookies

Cookies are not programs, and they cannot run like programs do. Therefore, they cannot gather any information on their own. Nor can they collect any personal information about you from your machine.

  • Here is a valid definition of a cookie:  “ A cookie is a piece of text that a Web server can store on a user’s hard disk. Cookies allow a Web site to store information on a user’s machine and later retrieve it ”.

 The pieces of information are stored as name-value pairs.

For example, a Web site might generate a unique ID number for each visitor and store the ID number on each user’s machine using a cookie file.

­ If you use Microsoft’s Internet Explorer to browse the Web, you can see all of the cookies that are stored on your machine. The most common place for them to reside is in a directory called c:windowscookies. When I look in that directory on my machine, I find 165 files. Each file is a text file that contains name-value pairs, and there is one file for each Web site that has placed cookies on my machine.

You can see in the directory that each of these files is a simple, normal text file. You can see which Web site placed the file on your machine by looking at the file name (the information is also stored inside the file). You can open each file by clicking on it.

For example, I have visited badrinathkadam.wordpress.com, and the site has placed a cookie on my machine. The cookie file for badrinathkadam.wordpress.com contains the following information:

UserID    A9A3BECE0563982D    http://www.badrinathkadam.wordpress.com/

badrinathkadam.wordpress.com has stored on my machine a single name-value pair. The name of the pair is UserID, and the value is A9A3BECE0563982D. The first time I visited badrinathkadam.wordpress.com, the site assigned me a unique ID value and stored it on my machine.
(Note that there probably are several other values stored in the file after the three shown above. That is housekeeping information for the browser.)

## How does cookie data move?

The data moves in the following manner:

    If you type the URL of a Web site into your browser, your browser sends a request to the Web site for the page (see How Web Servers Work for a discussion). For example, if you type the URL http://www.badrinathkadam.wordpress.com into your browser, your browser will contact wordpress’s server and request its home page.
    When the browser does this, it will look on your machine for a cookie file that wordpress has set. If it finds an wordpress cookie file, your browser will send all of the name-value pairs in the file to wordpress’s server along with the URL. If it finds no cookie file, it will send no cookie data.
    wordpress’s Web server receives the cookie data and the request for a page. If name-value pairs are received, wordpress can use them.
    If no name-value pairs are received, Amazon knows that you have not visited before. The server creates a new ID for you in wordpress’s database and then sends name-value pairs to your machine in the header for the Web page it sends. Your machine stores the name-value pairs on your hard disk.
    The Web server can change name-value pairs or add new pairs whenever you visit the site and request a page.

There are other pieces of information that the server can send with the name-value pair. One of these is an expiration date. Another is a path (so that the site can associate different cookie values with different parts of the site).

  • Web sites use cookies in many different ways. Here are some of the most common examples:

Sites can accurately determine how many people actually visit the site. It turns out that because of proxy servers, caching, concentrators and so on, the only way for a site to accurately count visitors is to set a cookie with a unique ID for each visitor. Using cookies, sites can determine how many visitors arrive, how many are new versus repeat visitors and how often a visitor has visited. Sites can store user preferences so that the site can look different for each visitor (often referred to as customization).

For example, if you visit http://www.badrinathkadam.wordpress.com/, it offers you the ability to “change content/layout/color.” It also allows you to enter your zip code and get customized weather information. When you enter your zip code, the following name-value pair gets added to badrinathkadam.wordpress.com cookie file:

WEAT  CC=NC%5FPune%2DDurham®ION=  http://www.badrinathkadam.wordpress.com/

    Since I live in Pune, N.C., this makes sense.
    Most sites seem to store preferences like this in the site’s database and store nothing but an ID as a cookie, but storing the actual values in name-value pairs is another way to do it (we’ll discuss later why this approach has lost favor).

  •  Disadvantages of Cookies :

Cookies are not a perfect state mechanism, but they certainly make a lot of things possible that would be impossible otherwise. Here are several of the things that make cookies imperfect.

    People often share machines – Any machine that is used in a public area, and many machines used in an office environment or at home, are shared by multiple people. Let’s say that you use a public machine (in a library, for example) to purchase something from an online store. The store will leave a cookie on the machine, and someone could later try to purchase something from the store using your account. Stores usually post large warnings about this problem, and that is why. Even so, mistakes can happen. For example, I had once used my wife’s machine to purchase something from Amazon. Later, she visited Amazon and clicked the “one-click” button, not realizing that it really does allow the purchase of a book in exactly one click. On something like a Windows NT machine or a UNIX machine that uses accounts properly, this is not a problem. The accounts separate all of the users’ cookies. Accounts are much more relaxed in other operating systems, and it is a problem. If you try the example above on a public machine, and if other people using the machine have visited HowStuffWorks, then the history URL may show a very long list of files.

  Cookies get erased – If you have a problem with your browser and call tech support, probably the first thing that tech support will ask you to do is to erase all of the temporary Internet files on your machine. When you do that, you lose all of your cookie files. Now when you visit a site again, that site will think you are a new user and assign you a new cookie. This tends to skew the site’s record of new versus return visitors, and it also can make it hard for you to recover previously stored preferences. This is why sites ask you to register in some cases — if you register with a user name and a password, you can log in, even if you lose your cookie file, and restore your preferences. If preference values are stored directly on the machine (as in the MSN weather example above), then recovery is impossible. That is why many sites now store all user information in a central database and store only an ID value on the user’s machine. If you erase your cookie file for HowStuffWorks and then revisit the history URL in the previous section, you will find that HowStuffWorks has no history for you. The site has to create a new ID and cookie file for you, and that new ID has no data stored against it in the database. (Also note that the HowStuffWorks Registration System allows you to reset your history list whenever you like.)

 Multiple machines – People often use more than one machine during the day. For example, I have a machine in the office, a machine at home and a laptop for the road. Unless the site is specifically engineered to solve the problem, I will have three unique cookie files on all three machines. Any site that I visit from all three machines will track me as three separate users. It can be annoying to set preferences three times. Again, a site that allows registration and stores preferences centrally may make it easy for me to have the same account on three machines, but the site developers must plan for this when designing the site. If you visit the history URL demonstrated in the previous section from one machine and then try it again from another, you will find that your history lists are different. This is because the server created two IDs for you, one on each machine.

I hope this is Helpful to all.