How to use HTML5 Web Storage

This article describe you about HTML5 Web storage.
  • 1853

HTML5 - Web Storage

Like to HTTP Session Cookies, HTML5 also introduces two mechanisms, for storing structured data on the client side and for this overcome following drawbacks.

  • When HTTP request, Cookies are created and for this your web application transmit the same data.
  • Data are unencrypted over the internet, because Cookies are included with the every HTTP request.
  • Cookies are text file that store limited amount of data about 4 KB.

These two mechanism Session storage and Local storage (Cookie) store the information in different situation

The mostly modern browser support HTML5 storage.

The Session storage designed  for store the user id carrying out a single transaction, but can multiple transaction with different windows.

suppose a user buying a railway tickets in two different windows, from the same site. If this site store information in the Cookies to keep track by which user buying which ticket, then user go to other window by clicking , the ticket currently bought would "leak"

from one window to another. For this user buy two ticket of same railway without any notice.

For access information on to the any page in the same site HTML5 also introduce Session storage.


<script type="text/javascript">
if (sessionStorage.hits) {
sessionStorage.hits = Number(sessionStorage.hits) + 1;
} else {
sessionStorage.hits = 1;
document.write("Total no Hits :" + sessionStorage.hits);
<p>If you will Refresh the page Then increase number of hits.</p>
<p>And Close the window and open it again then check the result.</p>

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.