开发者

Trying to expire a jquery.cookie within 3 minutes but no luck

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.

开发者_如何学Go
var date = new Date();
date.setTime(date.getTime() + (5 * 60 * 1000));
$.cookie("leftCol", "collapsed", { expires: date });


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.


$.cookie("leftCol", "collapsed", { expires: "2m" });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜