O'Reilly logo

The Book of JavaScript, 2nd Edition by thau!

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Cookie-Based Shopping Cart

You can build fairly complicated applications using cookies. This section discusses code that represents the start of a shopping cart script. You definitely do not want to use this code to run your own shopping cart—it's much too simplistic. For example, you can't remove an item from the basket once you've selected it.

However, this code should give you an idea of how to start building complex applications using cookies. Figure 12-10 shows you the code for a main page of a simple shopping cart (see Figure 12-11) with simple links to pages that contain items to buy.

The shopping cart main page

Figure 12-10. The shopping cart main page

Figure 12-11. What ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required