In this article, we will discuss local storage and session storage.
Developers often use Web Storage API to store some data into the web browser. Web storage objects localStorage and sessionStorage allow to save key/value pairs in the browser.
Advantages of Local Storage and Session Storage over Cookies
They are not sent to the server like cookies on every request.
Storage is bound to the origin.
Limit of storage is 5MB, it depends on the browser.
Local Storage
Data stored in local storage is shared between all tabs and windows from the same origin. The data do not get lost even after browser restart or reboot.
Output:
Session Storage
This exists only within the current browser tab. Data in session storage is cleared when the page session ends.
Output:
That's it for this article.