What is the maximum size of a web browser's cookie's key?

前端 未结 5 1634
北恋
北恋 2020-11-22 04:35

What is the maximum size of a web browser\'s cookie\'s key?

I know the maximum size of a cookie is 4KB, but does the key have a limitation as well?

5条回答
  •  死守一世寂寞
    2020-11-22 05:18

    A cookie key(used to identify a session) and a cookie are the same thing being used in different ways. So the limit would be the same. According to Microsoft its 4096 bytes.

    MSDN

    cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. By using a single cookie with subkeys, you use fewer of those 20 cookies that your site is allotted. In addition, a single cookie takes up about 50 characters for overhead (expiration information, and so on), plus the length of the value that you store in it, all of which counts toward the 4096-byte limit. If you store five subkeys instead of five separate cookies, you save the overhead of the separate cookies and can save around 200 bytes.

提交回复
热议问题