Two types of storage are in HTML5
- Local Storage : In this object stores data for a larger period of time even if the browser is closed.
- Session Storage : In this object stores data for a specific session.
Using local storage in modern browsers is ridiculously easy.
You can do that directly use the setItem() and getItem() method:
If you read out the favoriteflavor key, you will get back “vanilla”:
To remove the item, you can use- the removeItem() method:
That’s it! You can also use sessionStorage instead of localStorage if you want the data to be maintained only until the browser window closes.