localStorage is a property of the HTML5 API that allows web applications to store data locally in a user browser.
Prior to HTML5, application data must be stored in cookies included in each server request. localStorage is another property that has many advantages over cookies.
HTML local storage provides two objects for storing data on the client:
window.localStorage - stores data without expiration
window.sessionStorage - stores data for one session (data is lost when you close the browser tab)
localStorage:
- LocalStorage data has no expiration date.
- localStorage is more secure since it does not send anything to the server, everything happens on the client side, i.e. in the browser.
- localStorage at the beginning means that two or more html pages, from one source, can store and access the same data stored in the localStorage object.
- It can store much more data than cookies. The storage size varies for each browser, for example, the latest versions of chrome and firefox can store at least 5 MB of data.
source share