HTML5 Web Storage, localStorage and sessionStorage

localStorage and sessionStorage is extend HTML5 Web Storage. localStorage, sessionStorage and cookies are all client storage solutions. It store data locally within the clients browser. Cookies was the old method to store data locally before HTML5, HTML5 localStorage is more secure and store large amounts of data locally. You can improve your Website Performance using localStorage.

HTML5 localStorage has two objects for storing data locally

window.localStorage - Stores data with no expiry date

window.sessionStorage - Stores data for one session (Clear the data when the tab close)

Store and get data using localStorage

Stores the data with no expiration date using localStorage. The data will not loose when user close browser.

localStorage.companyname = "Zymphonies";

Store and get data using sessionStorage

Stores the data only one session. The data will clear when the user close the browser.

sessionStorage.companyname = "FreeBiezz";