Uncategorized

HTML5 web storage

HTML5 web storage

HTML5 has introduced feature, HTML5 web storage. HTML5 web storage allows us to store data on web browser/client machine. Now we can create apps that can run offline too, itsnt it amazing ??


HTML5 web storage is also know as Local storage which is same like cookies but there are few improvements in HTML5 web storage, removing drawbacks of tradition cookies. cookies has some limitation and drawbacks like

  1. Short storage space (4kb only)
  2. cookie data gets transmitted over HTTP header, It sends data over HTTP in unencrypted form, so if your application is not served over SSL it would be a big security hole.
  3. Bandwidth used to transmit the cookies is wasted


There are basically two types of HTML5 web storage introduced. We can differentiate them on the basis of scope and lifetime.

  • Local Storage
  • Session Storage

Local Storage

Local storage can be available to all scripts from the domain that originally stored the data. Local storage even persist after you close the tab. You need to manually remove it using javascript or need to clear browsers cache.

Local storage usage

Session Storage

Session storage is non persist, so if you close the browser session storage will be flushed and values will be no longer accessible. Data stored in session storage is accessible only from the domain that initially stored it. web browsers themselves clear session storage when we close it.

Sessionstorage usage

Have a look at HTML5 web storage demo page to see how it works.

4 Comments

Leave a Comment

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Shares

Let your friends know what are you reading

Share this post with your friends!