spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / cookies 123456

JavaScript Cookies:

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Making the Most from the Drudgery of Others

What they are

Put 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 123456

http://www.internet.com

Comments are welcome
Produced by Greg Meckes

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: Jan. 12, 2000
Revised: Jan. 12, 2000

URL: http://webreference.com/programming/javascript/cookies/page2.html