Reputation: 911
I want sliding time for expiration time of cookie. This can be done by getting cookie and again setting with new expiration time and deleting previous cookie. But , I want to know better way than this . I need some good solution.
Upvotes: 3
Views: 11925
Reputation: 46208
By "sliding time" I'm assuming you want the cookie to renew itself whenever the visitor reloads the page. Just reset the cookie every time the page loads (i.e. every time the JavaScript code is executed).
https://developer.mozilla.org/en-US/docs/DOM/document.cookie
However if you're looking for something more long term with more capacity then I would recommend using localStorage
:
https://developer.mozilla.org/en-US/docs/DOM/Storage#localStorage
Upvotes: 6