Example 7—Controlling Cookies

The final example here looks at how you can take control over cookies with JavaScript. Cookies are more widely used on the Web now than ever before to personalize Web content for frequent visitors (not to mention the tracking capability cookies provide, which is useful for marketing and sales purposes!).

Cookies are unique pieces of information a Web site gives the browser. The next time the browser goes to that site, invariably the information contained in that cookie is read. This enables the Web site to remember that you've been there before.


The individual bits of information contained in a cookie are, not surprisingly, called crumbs!

JavaScript lets you do some clever things with cookies. They can let ...

Get JavaScript™ 1.5 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.