gpt4 book ai didi

asp.net - 将 cookie 过期设置为 DateTime.Max(9999 年 12 月 31 日)时出现问题?

转载 作者:行者123 更新时间:2023-12-02 10:43:31 34 4
gpt4 key购买 nike

我们支持删除 cookie 并将过期时间设置为 DateTime.MaxValue 的旧代码:

HttpCookie cookie = new HttpCookie(cookieName, value);
cookie.Expires = DateTime.MaxValue;

似乎在某些浏览器(我们没有记录)上,此 cookie 会立即过期,或者甚至可能不会被删除。根据 MSDN,DateTime.MaxValue 为 9999 年 12 月 31 日。将 cookie 过期设置为此日期是否存在与浏览器相关的问题?

正确的答案是更改到期日期,但此时我们无法更改生产代码。

最佳答案

如果我必须随机猜测为什么它不起作用,我会说它与 Unix epoch time 有关。 。从技术上讲,该值将在 2038 年 1 月 19 日凌晨 3:14:07 GMT 后溢出(在 32 位计算机上) - 因此此后的下一秒将被解释为 1970 年 1 月 1 日凌晨 0:00:01 GMT。

您提供的 future 时间可能实际上已转换为过去时间。

再次强调,这完全是猜测,希望当 VWD Express 2008 下载到我的家用计算机上时我可以尽快对其进行测试。

编辑:

搜索这个问题,发现了类似的错误:

http://framework.zend.com/issues/browse/ZF-5690

关于asp.net - 将 cookie 过期设置为 DateTime.Max(9999 年 12 月 31 日)时出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/813904/

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