In this article we will learn how easy to store information locally on user’s computer by using HTML5 Local Storage. It is a very powerful strategy and very useful for a web developer. Local storage store and access data per domain & per protocol for all pages of your application.
By using HTML5 local storage you can store your web page’s CSS, Javascript files and images locally ot reduced server usage
Your web application was used cookies to stored data in your local machine before, but now days you can store larger amounts of data in locally in the browser by using HTML5 local storage features and this is more secure compare of cookies.
Web Browser Support
Most popular browsers supports HTML5 local storage.
Storing and Retrieving Local storage Values
There are many ways to store and retrive HTML5 local storage value. Below is the one of them :
1 2 3 4 5 | // setItem Method to save data to the current local store localStorage.setItem( "name", "Freewebmentor" ); // Retrieve your saved local stored data alert( "name = " + localStorage.getItem("name")) |
In the above code setItem() method used to save data in current local storage and localStorage.getItem method used to retrieve your local storage data.
Read:
Hotel Search using Google Maps JavaScript API v3
Facebook style confirm alert box
Text box validation alert message using jquery
Conclusion
If you are building your application which extensively interact with larger data, then i recommend to use HTML5 local storage. If you like this article, subscribe our newsletter and share it with your friends!
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: HTML 5, html5 local storage tutorial, Javasrcipt, local storage, Store data in user's computer