Reputation: 11
I need the cookie to expire automatically after 3 minutes but the following snippet of code from my jquery.cookie.js file is not working. The cookie reads "session" instead of an expiration date.
var date = new Date();
date.setTime(date.getTime() + (5 * 60 * 1000));
$.cookie("leftCol", "collapsed", { expires: date });
Upvotes: 1
Views: 2759
Reputation: 2752
It looks OK to me. The following is what I would use for 3 minutes (I don't like calling vars 'date', but that's irrelevant).
var expDate = new Date();
expDate.setTime(expDate.getTime() + (3 * 60 * 1000));
$.cookie("leftCol", "collapsed", { expires: expDate });
If your cookie shows "session", you're probably looking at the wrong cookie, or something else has overwritten it before you read it.
Upvotes: 2