How to use HTML5 Local Web Storage

This article describe you about Local Web Storage in HTML5.
  • 1795

Local Web Storage:

The local Storage is designed to store the information locally on the client side window, local storage can store the information of multiple client. And also increase the storage capacity, such technique are used in the client side to increase the performance reason. 

Cookie cannot handle very well because with each request cookie transmitted


LocalStorage attitude is used to access the page from the localStorage area without taking time because this storage will be available whenever use that page.

Example: Here below given the code set a local storage variable and access that variable every time when this page is accessed, next time also when you open the window.

<script type="text/javascript">
if (localStorage.hits) {
localStorage.hits = Number(localStorage.hits) + 1;
} else {
localStorage.hits = 1;
document.write("Total No of Hits :" + localStorage.hits);
<p>If you wil refresh then page to increase number of hits.</p>
<p>If Close the window and reopen it again then check the result.</p>

Note: This code store the information locally  persistent so if you close the window but information does not lost

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.