Skip to content Skip to sidebar Skip to footer

Make A Cookie Expire In One Hour

I have some code for a cookie that i want to make expire in 1 hour the code is: function createCookie(name,value,days) { if (days) { var date = new Date(); date.set

Solution 1:

Your function is using a days argument that is only changing minutes, not days since 60*1000 is 60 seconds in milliseconds. You should rename that argument to minutes, and then you can easily see that you just need to multiply the numberof hours by 60.


Post a Comment for "Make A Cookie Expire In One Hour"