| home / programming / javascript / cookies |
|
|
Making the Most from the Drudgery of OthersWhat they arePut simply, cookies are small files that a Web server puts on your hard drive. As Netscape puts it: "A cookie is a small piece of information stored on the client machine in the cookies.txt file." It's a way of storing data for later retrieval, even after you disconnect or return to the site later. This data is known as "persistent" because the cookie remains active throughout various browser sessions. Why cookies? Well, for many reasons. Let's assume that I'm the guy who wants to put a cookie on your hard drive. What reason would I have to do this? For one thing, I can make your visit to my Web site personalized by automatically sending you to a Web page with content that you have previously selected. Yahoo! and Netscape's "My Yahoo!" and "My Netscape" are good examples. You can increase the quality of your Web site with cookies by tracking where people go, and molding your site content based on where the traffic is headed. When you go to an online store for example, and want to order various items, the server needs to keep track of your choices and preferences. This can be easily accomplished with a cookie. If there were no cookies involved, you would have to write down everything as you click through the store, and retype it in at the end. What a pain in the neck! If we were to use a comparison to say, a real life shopping excursion, this is what it would be: Suppose you have to go to a HUGE hardware store to find a specialty part that you use frequently. To get it, you have to drive to the store, navigate through the entire store weaving in and out of all the aisles, and peruse the shelves to find it. Then you have to go to the cashier and wait in line to check out. Then the parking lot... You get the idea. If a cookie were used in this situation (and in real life I wish they were!), you could simply walk through the front door and have the item handed to you. There would be no fuss and no muss. The "cookie" information is stored with you and when you go in, the store reads it and viola - you're good to go. There are myriad applications in which you would want to use cookies; they mainly involve "Maintaining State" within a site or page. With HTTP (Hypertext Transfer Protocol), this is accomplished with the request/response method that exists in the HTTP Header (more on this later). You can obviously see the advantages of using cookies. |
| To Continue, Use The Arrow Buttons |
|
Comments are
welcome
Produced by Greg Meckes
Created: Jan. 12, 2000
Revised: Jan. 12, 2000
URL: http://webreference.com/programming/javascript/cookies/page2.html