Skip to content

Instantly share code, notes, and snippets.

View ngstwr's full-sized avatar

Nagesh Tiwari ngstwr

View GitHub Profile
@ngstwr
ngstwr / localStorage.js
Last active August 29, 2015 14:26 — forked from anhang/localStorage.js
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}