I have a simple HTML5 App that I am currently working on and I\'m wondering if it\'s possible to remove a item in HTML5 Local Storage after a period of time, like: after 24 hour
Use This Solution:
(function () {
var lastclear = localStorage.getItem('lastclear'),
time_now = (new Date()).getTime();
// .getTime() returns milliseconds so 1000 * 60 * 60 * 24 = 24 days
if ((time_now - lastclear) > 1000 * 60 * 60 * 24) {
localStorage.clear();
localStorage.setItem('lastclear', time_now);
}
})();