Use web storage to add offline capabilities
XMLHttpRequest, and something called web storage. This article discusses the power of web storage and why it’s a better storage method than cookies. Learn about the basic concepts, browser support, and the HTML5 web storage objects.
There are two types of web storage objects built in to HTML5:
sessionStorageobject stores data for a single session. If the user closes the page or browser, the data is destroyed.
localStorageobject stores data with no expiration date. The data remains stored when the web page or browser is closed, depending on the storage amount set for the user’s browser.
Both storage objects have the same methods and properties. For consistency, this article uses the
localStorage object throughout the examples.
In this article, learn about the power of web storage and why it is a better storage method than cookies. Explore the basic web storage concepts, HTML5 web storage methods, and browser support.
You can download the source code for the examples used in this article.