开发者

Cookie name length, uniqueness

开发者 https://www.devze.com 2023-04-08 15:21 出处:网络
I want to know what is the maximum value of the cookie name? Is the cookie name uniqu开发者_开发知识库e per domain, and/or path? All those informations are specified in RFC 2965 - HTTP State Managemen

I want to know what is the maximum value of the cookie name? Is the cookie name uniqu开发者_开发知识库e per domain, and/or path?


All those informations are specified in RFC 2965 - HTTP State Management Mechanism.

A cookie name must be, like Jay said, unique within a path.

The RFC also specifies that there should be no maximum length of a cookie's name or value (in ) :

From chapter 5.3 - Implementation Limits

Practical user agent implementations have limits on the number and size of cookies that they can store. In general, user agents' cookie support should have no fixed limits. They should strive to store as many frequently-used cookies as possible. Furthermore, general-use user agents SHOULD provide each of the following minimum capabilities individually, although not necessarily simultaneously:

  1. at least 300 cookies
  2. 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)
  3. at least 20 cookies per unique host or domain name

User agents created for specific purposes or for limited-capacity devices SHOULD provide at least 20 cookies of 4096 bytes, to ensure that the user can interact with a session-based origin server...

In practice, each browsers defines it's own maximum length. For more concrete data on the subject, you can consult the following stackoverflow question : What is the maximum size of a web browser's cookie's key?.


It must be unique within a path.


I dont know about max size but each cookie should not be more than 4,000 characters and in all practicality it should not be more that 2000 characters

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号