Web Storage js

html 5 introduces a new way to store our data locally. previously it was called as cookies but we can e store max of 4kb quite a tooo small one.so in the latest html5, dev can sotre data locally upto 10mbs. this can be done using web Storage. it has two branches.

1. sessionStorage and
2. localStorage

sessionStorage holds the data till the browser is open. when it is closed, all data gone.
localStorage holds data for long time. so no need to worry abt the loss of data.

here is sample code…

sign_up.html contain the js code which store the data locally

function signup() {
var dt = new Date();
var utcDate = dt.toGMTString();
if(typeof(Storage) !== “undefined”) {

alert(“doest not support”);

here the key is user name and the value is an array which hold data,email and password.


function check() {

if(typeof(Storage) !== “undefined”) {
var array=[];
var arr = str.split(“,”) ;

if(document.getElementById(‘ps’).value == arr [0]){
alert(“Sucess… u r redirecting to the main page”);
alert(“Invalide username or password”);

alert(“browser not support”);


here it gets the user name and check with the key value pair and check for the correct password.

happy coding:)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s