gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 22:31:16 24 4
gpt4 key购买 nike

我这样做了:

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com