How Cookies Work
A cookie is data that is placed on your computer by a Web server. The data contains several lines of text, and is stored on a special folder on your hard disk. Later, the Web server can retrieve the cookie, examine it, and leave another one if it wants to. A copy of the cookie is sent back to the Web server when you revisit their site.
Cookies can store usernames and passwords, so that you do not always have to type them in when you visit the site. They can also enable you to fill electronic shopping carts.
When you visit a site, your browser examines the URL, and looks into your cookie folder. If it finds a cookie from this URL, it sends the information to the server, enabling the server to use it. If there is no cookie related to this URL, the server will place a cookie on your hard disk. Usually a CGI (Common Gateway Interface) script will write the cookie onto your hard disk. CGI is a communications protocol that enables Web servers to communicate with applications, such as databases.
While you travel through a Web site, more information may need to be placed in your cookie. If this happens, a CGI script will delete your cookie and write a new one. After you leave the site, the cookie remains on your hard disk so that you can be recognized the next time you visit the site.
If you want to buy something online and the site asks for your credit card number, it will not be stored in a cookie for security reasons. Instead, it is stored on a secure server. When you decide to make a purchase, your cookie sends an ID to the server, identifying you, then the server displays your credit card information allowing you to buy online.
Browsers give you the option of accepting all, none, somewhere in between, or to be asked every time a cookie is going to be placed on your hard disk. You can make this choice based on your personal preferences, however, you will not be able to visit some sites if you do not accept their cookies.