gpt4 book ai didi

javascript - 我的 Javascript cookie 在 session 时过期,而不是 30 天后

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:49:48 25 4
gpt4 key购买 nike

jQuery(document).ready(function(){
if (document.cookie.indexOf('visited=true') === -1) {
var expires = new Date();
expires.setDate(expires.getDate()+30);
document.cookie = "visited=true; path=/; expires="+expires.toUTCString();
jQuery.colorbox({open:true,href:"<?=home_url()?>/popup/?site_type=2",iframe:true, innerWidth:"700px", innerHeight:"410px"});
}
});

此 cookie 在我关闭浏览器时过期,但我希望它持续 30 天,直到他们再次看到弹出窗口。

最佳答案

不使用 expires,尝试使用 max-age(以秒为单位)。这不涉及创建和修改 Date 实例。

if (document.cookie.indexOf('visited=true') === -1) {
document.cookie = "visited=true; path=/; max-age=2592000;";

关于javascript - 我的 Javascript cookie 在 session 时过期,而不是 30 天后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10305647/

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