HTML5 Storage can be very useful to increase performance in applications. Why do a round trip to the web server, when we can store this data in a browser cache object?
HTML5 Storage is available in all modern browsers with a capacity limited to 5MB of data, but Internet Explorer supports a limit of 10MB.
localStorage and sessionStorage are two JavaScript object-storing key-value pairs. If the value is a complex JavaScript object, it has to be stored as a JSON string, using JSON.stringify().
The differences between them both are:
- The sessionStorage shares data in the same tab or window during a navigation session
- The localStorage shares data between all tabs and windows, with no time limitation