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 hours, remove this item, etc.
I'm thinking that Date Object built into JavaScript would probably be what I need.
Is this possible? Some code examples would be nice if you could, thanks!
ps: nicwincount is a localstorage you set before. localStorage.setItem('feeds', Ext.encode(feeds));
hope can help you.
If you want to do this I think you basically have to do it manually. For example, you could store the timestamp in a localStorage slot alongside each value you're storing, and then check the timestamp against the current time at some regular interval like page load or setTimeout or something.
Example:
EDIT: mrtsherman's method would totally work as well. Similarly, you could enter the timestamp as a property of an object you might be storing/retrieving with JSON.stringify/parse(). If either the array or the object are very large, or you have very many of them, I'd probably suggest using the parallel property method for efficiency, though.
Use This Solution:
You could store the date along with the data