Safari 5不会将所有cookie发送回服务器 [英] Safari 5 not sending all cookies back to the server

查看:79
本文介绍了Safari 5不会将所有cookie发送回服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到Safari 5出现了这个问题(实际上至少从4.0.5版本开始就很普遍),似乎它无法正确设置Cookie。该网站可以在Firefox,IE和Chrome上正常运行。

I'm seeing this issue with Safari 5 (actually it has been prevalent since at least 4.0.5), where it seems that it does not set cookies properly. The site works perfectly fine for Firefox, IE, and Chrome.

不过,我可以通过查看Safari使用的cookie plist来验证cookie的设置是否正确。在Windows 7上,它存储在以下位置:C:\Users\\AppData\Roaming\Apple Computer\Safari\Cookies\Cookies.plist

However, I can verify that the cookie is being properly set by looking at Safari's cookies plist that it uses. On Windows 7 it's stored here: C:\Users\\AppData\Roaming\Apple Computer\Safari\Cookies\Cookies.plist

现在,我正在工作的网站使用Cookie的方式非常广泛,并且存储在不同的域中。

Now the site that I am working on uses cookies quite extensively and are stored across different domains.

例如,该网站是www.foo.com。
登录cookie设置为domain .foo.com。
此外,其他cookie也存储到域www.foo.com,a.foo.com,b.foo.com等。

Let's say for example, the site is www.foo.com. The login cookie is set to domain .foo.com. In addition, other cookies are stored to domain www.foo.com, a.foo.com, b.foo.com, etc.

Safari似乎在进入www.foo.com时会感到困惑,并忘记发送它应该发送的所有cookie(www.foo.com,.foo.com)。

Safari seems to get confused when going to www.foo.com and "forgets" to sends all of the cookies that it should (www.foo.com, .foo.com).

我不确定这是我的错误(cookie中的无效字符)还是Safari的错误。我想知道是否有人遇到过

I am not sure if this is an error on my side (invalid characters in the cookie) or if this is a bug with Safari. I'd like to know if anybody has come across this and has found a

谢谢!

编辑:我关注的一个cookie很大,长度不到4k。它包含编码信息,并且包含的​​字符是字母数字和/ + _ =

Edit: The one cookie that I am concerned about is quite big, a little less than 4k in length. It contains encoded information and the characters that it consists of are alphanumerics and / + _ =

现在,奇怪的是,根据Cookie设置的域, cookie本身可以正常工作。但是,当用户登录时,会添加另一个cookie,而Safari似乎会忽略第一个cookie。 Safari很好地发送了登录cookie,它由字母数字以及[] _ \

Now what's strange is that, depending on the domain the cookie gets set to, the cookie works fine by itself. However, when the user logs in, another cookie gets added and Safari seems to ignore the first one. Safari sends the login cookie fine and it consists of alphanumerics along with [ ] _ \

组成。我最初的想法是这可能是域冲突。第一个cookie设置为www.foo.com,而登录cookie设置为.foo.com。但是,我测试了这个理论,将它们都设置为.foo.com,问题仍然存在。

My original thought was that it could be a domain conflict. The first cookie was being set to www.foo.com while the login cookie was being set to .foo.com. However, I tested this theory, setting them both to .foo.com, and the issue still remains.

推荐答案

看看在浏览器的大小限制中此处。 Safari 5的每个请求限制为4kb。因此,如果该域(包括相关的通配符域)的所有cookie的总大小超过4k,您将开始丢失cookie。
我相信逻辑是最老的cookie将首先被牺牲,直到cookie头的总大小小于4k。

Have a look at the browser size limits here. Safari 5 has a 4kb limit per request. So if the total size of all cookies for the domain (including associated wildcard domains) exceeds 4k, you'll begin to lose cookies. I believe the logic is that the oldest cookie will be sacrificed first, until the total cookie header size is below 4k.

我们目前遇到了一个问题我们自己也遇到了这个问题,但还发现了丢失cookie的另一种情况,尽管我们还没有弄清楚为什么会这样。

We're currently having an issue with this problem ourselves, but have also identified another scenario in which cookies are lost, though we've yet to understand why this is the case.

鉴于您的单个cookie,则可能是以下请求添加了一个新cookie,使总大小超出了限制。

Given the large size of a single cookie of yours, it's likely that a following request adds a new cookie, bumping the total size over the limit.

这篇关于Safari 5不会将所有cookie发送回服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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