Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

HTML5 Local Storage

Tags: html store cookie

HTML5 Local storage is a great feature introduced to Store data in the browser.

It is similar to cookies but storage is very large compare to cookies. Usually, modern browsers stores local storage data minimum 5 MBs default until user sets limit explicitely.

Hence, you can use it for your application data storage which does not require data to be sent to the server and can be utilized client side only.

When properties are set in HTML5 local storage, it will be accessible only by the pages from the same domain for the security purpose.

Local storage feature can be used using two ways:
  1. sessionStorage
  2. localStorage
Use localStorage to set key and value like this:


sessionStorage.setItem("myKeyName", "Hello World");
localStorage.setItem("myKeyName", "Hello World");

Read key from browser like this:

var myVar = sessionStorage.getItem("myKeyName");
var myVar = localStorage.getItem("myKeyName");


This post first appeared on Frontend Skills, please read the originial post: here

Share the post

HTML5 Local Storage

×

Subscribe to Frontend Skills

Get updates delivered right to your inbox!

Thank you for your subscription

×