我有这个:
if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 5 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString();
10分钟后如何让Cookie过期?
解决方法
var date = new Date(); var m = 10; date.setTime(date.getTime() + (m * 60 * 1000)); $.cookie("cookie","value",{ expires: date });
或者,您可以使用一个函数:
function ExpireCookie(minutes) { var date = new Date(); var m = minutes; date.setTime(date.getTime() + (m * 60 * 1000)); $.cookie("cookie",{ expires: date }); }
然后做expireCookie(10);