Tip 27Saving Preferences with Web Storage

The Web Storage mechanism provides a simple method for developers to persist data on the client’s machine using a name/value store built into the web browser. With a very small amount of JavaScript, storing and retrieving simple strings of data is a breeze. It’s one of the most widely available storage application programming interfaces (APIs), implemented in Internet Explorer 8 and the old versions of iOS and Android browsers.

Data stored in Web Storage’s localStorage system persists between browser sessions and can’t be read by other websites, because it’s restricted to the domain you’re currently visiting. Just watch out when you’re developing things locally. If you’re working on a local server, like ...

Get HTML5 and CSS3, 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.