Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  100] [ 2]  / answers: 1 / hits: 45094  / 12 Years ago, mon, october 22, 2012, 12:00:00

Possible Duplicate:

When do items in HTML5 local storage expire?






My web application uses client side storage (sessionStorage and localStorage). However, I want this data to be expired after some time (eg. 2 days). It was a super easy task with expiration date of cookies but I don't know how to set an expiration date for HTML5 storage.



Any ideas how to solve this problem? Efficiency and simplicity is important.


More From » html

 Answers
60

The best you can do is to set a timestamp in storage, and if the user visits your site after a specified amount of time, then you can delete the stored data.



sessionStorage should work the same way, except when it doesn't even last long enough for your timed expiration. In that case, it'll expire sooner.


[#82424] Sunday, October 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lawrencem

Total Points: 153
Total Questions: 102
Total Answers: 98

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
lawrencem questions
;