HTML5 Storage

Added in HTML5.
There are two objects for storing data on the client.

window.localStorage 
window.sessionsStorage


Browser Support

Check the browser supports this

if (typeof(Storage) !== "undefined") { 
   // code for localStorage and sessionStorage
} else {
   // not supported
}

localStorage

Stores data with no expiry date

localStorage.setItem("fieldname", "BetterSolutions"); 
document.getElementById("element").innerHTML = localStorage.getItem("fieldnamed");


sessionStorage

Stores data for only one session
When the borwser is closed the data is lost



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext