In my JS code, I have this:
var expiredays = "1";
which sets a “cookie” to expire in 1 day. However, I want it to expire in 1 hour instead. Is there a way to do that?
Thanks
In my JS code, I have this:
var expiredays = "1";
which sets a “cookie” to expire in 1 day. However, I want it to expire in 1 hour instead. Is there a way to do that?
Thanks
Yes, use Expires and set it to a date that’s 1 hour ahead of now.
If you use the createCookie function from these cookie handling functions then you can give it a day of 1/24 to have it expire in 1 hour.
Thanks for the reply. Here is the snippet of code. How would I write this for 1 hour? Thanks:
function BookMark() {
$('#BookmarkImg').animate({ "top": "-81px" }, 1000);
baseCookieName = "rwbookmark";
var exdate = new Date();
var expiredays = "1";
exdate.setDate(exdate.getDate() + expiredays);
//use of arbritary stop point so no endless loop occurs
for (var i = 0; i < 10000; i++) {
var curName = baseCookieName + i;
if (document.cookie.indexOf(curName) < 0) {
document.cookie = curName + "=" + escape(window.location.href) + "[#]contentid=" + document.getElementById("inputContentID").value + "[#]title=" + GetPageTitle() + ";expires=" + exdate.toGMTString() + ";path=/;domain=domain.ca;";
break;
}
Use setTime instead of setDate, as in the code that I linked you to before.
For example:
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));