Reputation: 1
i have countdown timer in java script ,i want to retain the countdown time even when the page is refreshed can you please suggest me what direction i have to follow
Upvotes: 0
Views: 471
Reputation: 348992
Don't use cookies, because they add unnecessary overhead to your page requests.
Use localStorage
instead (compatibility table (polyfills)):
var countdowntimervalue = 100; // Some variable
localStorage.setItem('timer_value', countdowntimervalue); // <-- Set the value
To get the value at a later point use:
var saved_value = localStorage.getItem('timer_value');
Upvotes: 1
Reputation: 4778
Use a cookie to set a timestamp, and then reference the timestamp in future page loads.
Upvotes: 0