Retrieving data from the Web Storage API is just as easy as storing it. The only thing you need to be careful of is that the context of what you access will be retrieved as a string, so if you are expecting a number or object type, some post-retrieval conversion is required.

All Web Storage events occur relative to the user’s current domain. This means that if a user visits your website at, anything stored there can be accessible only from other JavaScript code running within

There are different ways to retrieve data stored in the Web Storage API:

string = localStorage.getItem(key);
string = sessionStorage.getItem(key);

This will return null

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.