If you haven’t heard, HTML5 Localstorage allows us web developers to store data within the client’s browser. This is different than cookies which are transmitted with every request to the server. Localstorage allows us to put data into the browser’s storage once and not have to transmit it back and forth.
Using local storage is super easy. It acts just like a hashtable and is accessed through a global JS variable called “localStorage”.
var foo = localStorage.getItem("bar"); localStorage.setItem("bar", foo);
Boom, you’ve retrieved an item and set an item! If an item doesn’t exist, it will just return null, not an exception like some hashtable implementations.
I’ve been using this to storage and retrieve Kendo Grid filters and sorts between page views. That’s for another blog post, though…