Reputation: 1903
I am creating a cookie using the jQuery cookie plugin. I want to limit it to 1 hour, instead of 1 day. Through the docs the lowest value that it gives an example of is 1 day. How can I lessen this value from 1 day, to 1 hour?
jQuery.cookie('data', data, { expires: 1 }); // this limits to 1 day
I came across this with just plan javascript, but It didn't seem to work for me with the plugin. Comes back with time() is not defined
jQuery.cookie('data', data, { expires: time()+3600 }); // this limits to 1 day
Is this possible?
Upvotes: 0
Views: 483
Reputation: 21911
Use a Date
object with the date of expiration
jQuery.cookie('data', data, {
expires: new Date(+new Date() + (60 * 60 * 1000))
});
Upvotes: 2