我这样做了:
$.cookie("ultOS", (i), {expires:1});
但它只会在第二天过期。
如何在午夜使 Cookie 过期?
这会起作用吗?
var date = new Date();
var midnight = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
$.cookie("ultOS", (i), {expires: midnight});
最佳答案
我认为这会起作用:
var currentDate = new Date();
expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);
$.cookie("ultOS", "5", {expires: expirationDate});
关于jquery - 如何使用 Jquery 在午夜使 Cookie 过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4627821/