Chapter 12. SAVING VISITOR INFORMATION WITH COOKIES

It's often helpful to remember a little bit of information about a visitor after he or she has left your site: a login name, the last time the visitor visited, or any customization preferences a visitor has set while visiting your site. To remember this information, you'll have to save it somewhere.

Chapter 10 showed you how to use frames to a store a visitor's answers to quiz questions. Unfortunately, after the browser is closed, this method does not retain the information the visitor entered. Cookies provide a solution to this problem: They let you save information on your visitor's computer for a specified length of time.

Cookies aren't hard to use, but the code for saving and retrieving them ...

Get The Book of JavaScript, 2nd 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.