Web Storage Types

HTML5 introduced two new APIs for in-browser persistent data storage: sessionStorage and localStorage.

The difference between the two is basically how long the browser persists the data.

Session Storage
Session Storage stores data only for the lifetime of the browser instance/session.

Session storage lets us keep track of data specific to one window or tab. Even if the user is visiting the same site in two windows, each window will have its own individual session storage object and thus have separate, distinct data.

Session storage is not persistent—it only lasts for the duration of a user’s session on a specific site (in other words, for the time that a browser window or tab is open and viewing that site).

Local Storage
Local Storage stores data persistently "forever."

Unlike session storage, local storage allows us to save persistent data to the user's computer, via the browser. When a user revisits a site at a later date, any data saved to local storage can be retrieved.

Note:-
Note
Data stored in these containers must be strings, so if you need to store complex data objects, one good option is to serialize the object into JSON, using JSON.stringify().
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +