什么是Web浏览器的cookie的键的最大尺寸? [英] What is the maximum size of a web browser's cookie's key?

查看:150
本文介绍了什么是Web浏览器的cookie的键的最大尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是网络浏览器的cookie的键的最大大小?

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

我知道一个cookie的最大大小为4KB,但关键有局限性呢?

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

推荐答案

4K容量的限制你阅读是整个饼干,包括名称,价值,有效期等,如果你想支持大多数浏览器,我建议保持名下4000字节,并且在4093字节的整体尺寸的cookie

The 4K limit you read about is for the entire cookie, including name, value, expiry date etc. If you want to support most browsers, I suggest keeping the name under 4000 bytes, and the overall cookie size under 4093 bytes.

有一点要小心:如果名称是太大了,你不能删除cookie(在JavaScript中至少)。 Cookie是通过更新它,将其设置为过期删除。如果名称是太大,说4090个字节,我发现我无法设置到期日。我只能看着这个出于兴趣,而不是我计划有一个名字那么大。

One thing to be careful of: if the name is too big you cannot delete the cookie (at least in JavaScript). A cookie is deleted by updating it and setting it to expire. If the name is too big, say 4090 bytes, I found that I could not set an expiry date. I only looked into this out of interest, not that I plan to have a name that big.

要了解更多关于它,这里是浏览器cookie限制的常见的浏览器。

To read more about it, here are the "Browser Cookie Limits" for common browsers.

虽然关于这个问题,如果你想支持大多数浏览器,然后不超过 50%域饼干,每个域 4093字节。也就是说,所有的cookies的大小不能超过4093字节。

While on the subject, if you want to support most browsers, then do not exceed 50 cookies per domain, and 4093 bytes per domain. That is, the size of all cookies should not exceed 4093 bytes.

这意味着你可以有1饼干的4093个字节,或2饼干的2045个字节,等等。

This means you can have 1 cookie of 4093 bytes, or 2 cookies of 2045 bytes, etc.

我常说,由于IE7 4095个字节,但是现在移动Safari浏览器与4096字节开始与每个Cookie 3字节的开销,因此4093最大字节。

I used to say 4095 bytes due to IE7, however now Mobile Safari comes in with 4096 bytes with a 3 byte overhead per cookie, so 4093 bytes max.

这篇关于什么是Web浏览器的cookie的键的最大尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆