Chapter 20Implementing Cookies

Maintaining a State

When you create a web site, you expect the user to load HTML documents, view them, navigate from one page to another, etc. Occasionally, it is important to enable the web page to maintain a state. That is, the page “remembers” certain actions executed by the user during previous sessions.

A classic example of maintaining a given state is a shopping cart application, as you might see on almost any commercial web site. The user travels from one product review to another via simple HTML links. When he or she comes across an interesting product, clicking a button puts the selected product’s data in a “shopping cart.” The shopping cart, which is sometimes displayed visually on the page, is basically ...

Get Advanced Javascript, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.