jquery - 如何使用 Jquery 在午夜使 Cookie 过期?

标签 jquery jquery-plugins

我这样做了:

$.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/

相关文章:

javascript - 如何将参数传递给 jQuery 中的事件处理程序?

jquery - 未捕获的类型错误 : view. css 不是函数

javascript - 了解插件的概念 - $/jQuery 未定义

javascript - 浏览器上的 native toast 消息

javascript - jQuery Calendar时间选择建议

javascript - 如何使用 jQuery 仅检索隐藏输入上逗号分隔值中的第二项

javascript - 使 jQuery 自动完成内的 <a> 可点击

jquery - 扩展 jQueryUI 小部件而不发生冲突

javascript - 如何解决 Cypress 中的悬停问题?

jquery - jScrollPane滚动条问题