Javascript - Session Storage


Session Storage is an alternative to storing information in a cookie so that session information can be maintained using javascript.

//save a value
sessionStorage.setItem("name", "Nicholas");

//retrieve item
var name = sessionStorage.getItem("name");

//get the key name for the first item
var key = sessionStorage.key(0);

//remove the key
sessionStorage.removeItem(key);

//check how many key-value pairs are present
var count = sessionStorage.length;
 
Here is the example in which we are checking that if there are values in the Session Storage , first load the arrays with those values.

if (sessionStorage.length != 0){
    for(i=0;i<=90;i++){
         if(sessionStorage.getItem(i) != null) {
            array.push(i);
        }
}

Related Link

http://techsharepoint.blogspot.com/2012/11/javascript-tambola-board-source-code.html