Lesson 9. Web Storage

One of the things that HTML authors have missed is some way of storing data between page accesses. When the page gets refreshed, all JavaScript variables get reset to their original values, for example. How can you store data that’s still there when the user comes back to your page?

This is often why people start working with server-side code—to preserve data between page accesses. However, now, in HTML5, there’s a new way. So, for example, if you’re keeping track of a user’s purchases, you can store that information so that it’ll be available when they come back to the page.

Using plain JavaScript and HTML5, you can now store data so that it’s there even after the current page is reloaded. You can store data in either ...

Get Sams Teach Yourself HTML5 in 10 Minutes 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.