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 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.