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.
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 :
// 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.
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]m. Your article will appear on the FreeWebMentor main page and help other developers.