tags:

views:

49

answers:

1

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 });
+1  A: 

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.

Jhong