简体   繁体   English

如果我超过最大 cookie 的限制会发生什么

[英]What happens if I exceed the limit of maximum cookies

As far as I read there is are two limits on the number of cookies :据我所知,cookie 的数量有两个限制:

  • 20 cookies per unique host or domain name每个唯一主机名或域名 20 个 cookie
  • a total of 300 cookies总共 300 个饼干

What does happen if I exceed one of these limits ?如果我超过这些限制之一会怎样?

Short Answer:简答:

  1. If you exceed the limits per host/domain, the cookies simply won't be saved .如果您超出每个主机/域的限制,则 cookie将不会被保存

  2. If you exceed the total number of cookies, Your browser will alert you that the maximum number of cookies has been reached如果您超过 cookie 的总数,您的浏览器会提醒您已达到最大 cookie 数量

Note that your question states that the max number of cookies per host is 20 and the total allowed is 300. However, this is not completely true.请注意,您的问题指出每个主机的最大 cookie 数为 20,允许的总数为 300。但是,这并不完全正确。 The number of maximum cookies is highly dependent on the Browser.最大 cookie 的数量高度依赖于浏览器。 For example,例如,

  • Chrome 9 allowed 180 cookies per domain Chrome 9 允许每个域 180 个 cookie
  • Firefox 3.6.3 allowed 50 cookies per domain Firefox 3.6.3 允许每个域 50 个 cookie

As far as the RFC spec goes, the minimum requirements are:RFC 规范而言,最低要求是:

  • at least 300 cookies至少300 个饼干
  • at least 4096 bytes per cookie每个 cookie至少4096 字节
  • at least 20 cookies per unique host or domain name每个唯一的主机名或域名至少有20 个 cookie

This resource can help you test browser cookie limits.资源可以帮助您测试浏览器 cookie 限制。 Also this SO post will shed some light on the design and performance aspect.此外,这篇SO 帖子将阐明设计和性能方面。

References : Cookie Limit per domain , Browser Cookie Restrictions参考资料每个域的Cookie 限制浏览器 Cookie 限制

我尝试通过快速循环(一次 100 个)添加大量 cookie,Chrome 69.0.3497 和 FireFox 62.0.3 删除旧的 cookie 并存储新的 cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM