瀏覽器的 Cookie 是做登入、紀錄、追蹤等等,最常使用的工具。
不過現在 Cookie 要放的東西越來越多,Cookie 到底可以塞的容量是多少呢?
- 註1:照標準應該是 4096 bytes,不過瀏覽器實作時,都可能會有些落差~
- 註2:下述取自此篇:RFC-2965 HTTP State Management Mechanism
- Practical user agent implementations have limits on the number and size of cookies that they can store.
- at least 300 cookies
- at least 4096 bytes per cookie (as measured by the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie2 header, and as received in the Set-Cookie2 header)
- at least 20 cookies per unique host or domain name
- Practical user agent implementations have limits on the number and size of cookies that they can store.
瀏覽器的 Cookie 容量限制 - 2018
IE、Chrome、Firefox、Safari 等等,允許 Cookie 的容量限制是如何,可以參考此篇:chrome cookie size limit(下述摘錄自此篇)
- According to RFC 1012 cookie size must not be limited by user agent. But the minimum capabilities of a browser or user agent should be at least 4096 bytes per cookie. This limit is applied to the name=value portion of the cookie only.
- So some browsers can support longer cookies as well. List :
- Internet Explorer 8 allowed cookies up to 4095 bytes
- Chrome 9 allowed cookies up to 4096 bytes
- Opera 11 allowed cookies up to 4096 bytes
- Safari 5 allowed coookies up to 4097 bytes
- Firefox 3.6.3 allowed cookies up to 4097 bytes
建議下述此篇必看,這篇有更詳細的「清單」與「即時測試」的功能,此篇除了 Size 外,還有每個 Domain 的 Max Cookie 可以設定的數量在各個瀏覽器版本的資訊。
- 詳見:Browser Cookie Limits - 大多數都是每個 Cookie size 4096 bytes,每個 Domain Cookie Max size 也是 4096 bytes 上下居多 (更新到 2017年)
相關網頁
- How Big Can a Web Cookie Be? - 下述摘錄自此篇:
- Google Chrome - 4096 bytes
- Internet Explorer - 5117 bytes
- Firefox - 4097 bytes