The localStorage and sessionStorage properties allow to save key/value pairs in a web browser.
localStorage:
localStorage object stores data with no expiration date.The data will not be deleted when the browser is closed, and will be available the next day, week, or year.
sessionStorage:
The Session storage
— Session storage uses the sessionStorage object to store data on a temporary basis, for a single browser window or tab.
Difference between localStorage and sessionStorage:
Session storage is destroyed once the user closes the browser whereas, Local storage stores data with no expiration date.