最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can't set a cookie to expire more than a week away - Stack Overflow

programmeradmin1浏览0评论

Both of these approaches end up in a max-age/expiry only 7 days in the future.

document.cookie = "testCookie=value; max-age=999999999";
document.cookie = "testCookie=value; expires=Fri, 31 Dec 9999 23:59:59 GMT";

I've also tried different values with both approaches and various cookie libraries to no joy.

Both of these approaches end up in a max-age/expiry only 7 days in the future.

document.cookie = "testCookie=value; max-age=999999999";
document.cookie = "testCookie=value; expires=Fri, 31 Dec 9999 23:59:59 GMT";

I've also tried different values with both approaches and various cookie libraries to no joy.

Share asked Jan 12, 2020 at 1:43 ChildishGiantChildishGiant 3401 silver badge13 bronze badges 2
  • It's not JavaScript issue only. When I've tried setting "year" cookie from PHP got age of ~6 months. Noticed that with Brave browser only. Well, I rarely use cookie older than 7 days so cheked this for curiosity only. – Wh1T3h4Ck5 Commented Jan 18, 2020 at 8:57
  • Apparently safari will be implementing this too – ChildishGiant Commented Jan 19, 2020 at 13:33
Add a ment  | 

2 Answers 2

Reset to default 10

Turns out this is intended behaviour in the Brave browser. See #3443 for more info

In new versions of browsers such as Chrome, a maximum limit of 400 days was set for the age of cookies.

发布评论

评论列表(0)

  1. 暂无评论