Most software applications need to store data in some sort of persistent fashion in order to be useful. When it comes to web apps, this task has traditionally been handled either with a server-side database or cookies set in the browser. With the advent of HTML5, web developers now have a few more options: localStorage, sessionStorage, and client-side databases.
Unlike cookies, however, localStorage and sessionStorage data is not sent across the wire with the browser request—it lives entirely in the client. Therefore, it’s feasible to store much more data than you would want to with cookies.
At the time of this writing, browser size limits for localStorage and sessionStorage are still in flux.
Functionally, localStorage and sessionStorage are the same. They differ only in terms of persistence and scope:
Data is saved even after the window is closed and is available to all windows (or tabs) that are loaded from the same source (must be the same domain name, protocol, and port). This is useful for things like application preferences.
Data is stored with the window object. Other windows/tabs are not aware of the values, and the data is discarded when the window/tab is ...