有些浏览器会对 cookie 进行编码吗?

发布于 2024-08-23 06:11:21 字数 815 浏览 4 评论 0原文

这是 为什么我的 cookie 偶尔包含 JSON 的后续内容格式错误,我们已解决。

我有一个 3 值 cookie,我们对主值进行 url 编码。另外两个值是时间戳和哈希值。在我们的响应标头中看起来像这样:

foo=d=634027688530013385&v=%7b%22HasDog%22%3afalse%2c%22Greeting%22%3anull%2c%22RecentRecipes%22%3a%5b%5d%2c%22Remember%22%3afalse%7d& h=ARv5QGf4Cnftc4tFaPoy/VH8Pbo=;路径=/;仅限 Http

在我们的日志中,我们看到无法正确解析这三个值的情况,因为整个 cookie 现在都已编码:

Cookie 看起来已损坏:d%3D634027653097874122%26v%3D%7B%22HasAcceptedTerms%22%3Afalse%2C%22RecipeBoxCount%22%3A0%2C%22Remember%22%3Afalse%7D%26h%3DR85mJ%2FTdA6yrVe5pVCVpfG2ju:毫米%3D

不幸的是,我们不捕获用户代理以查看这是否与特定浏览器相关。

我有几个选项可以解决这个问题。我只是觉得这种行为很奇怪,值得提出一个问题。

This is sort of a follow-up to Why are my cookies containing JSON occasionally malformed, which we have resolved.

I have a 3-value cookie, and we're url encoding the main value. The other two values are a timestamp and a hash. It looks like this in our response header:

foo=d=634027688530013385&v=%7b%22HasDog%22%3afalse%2c%22Greeting%22%3anull%2c%22RecentRecipes%22%3a%5b%5d%2c%22Remember%22%3afalse%7d&h=ARv5QGf4Cnftc4tFaPoy/VH8Pbo=; path=/; HttpOnly

In our logs, we see cases where we can't parse the three values correctly because the entire cookie is now encoded:

Cookie looks mangled: d%3D634027653097874122%26v%3D%7B%22HasAcceptedTerms%22%3Afalse%2C%22RecipeBoxCount%22%3A0%2C%22Remember%22%3Afalse%7D%26h%3DR85mJ%2FTdA6yrVe5pVCVpfG2jumM%3D

Unfortunately, we're not capturing the user agent to see if this is related to a specific browser.

I have several options to fix this. I just think the behavior is odd enough to warrant a question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

信愁 2024-08-30 06:11:21

这可能不是一个答案,但是……

这很有趣,值得更深入地研究。

我希望看到一个面向公众的测试页面,该页面显示红色或绿色,并以粗体文本显示 cookie,然后通过 http:// 运行它browsercam.com

当我认为我发现 mozilla 原生中的一个错误时,我这样做了json 支持。事实证明我是对的

在填写免费试用表格(200 个镜头)之前,确保您的测试页正常运行,将分辨率设置为 640/480 并选择所有浏览器/平台、182 种不同的组合,设置延迟以允许重定向设置cookie 并追查罪魁祸首。

或者花点时间访问 http://testswarm.com/

请您继续跟进此事。

This may not be an answer but....

This is interesting and warrants a deeper look.

I would like to see a public facing test page that shows red or green with the cookie in bold text and then run it through http://browsercam.com.

I did this when I thought I had found a bug in mozilla's native json support. turns out I was right.

Get your testpage working for sure for sure before you fill out the form for a free trial (200 shots), set the resolution to 640/480 and select all browsers/platform, 182 distinct combinations, set a delay to allow the redirection to set the cookie and track down the culprit.

Or take the time and get on http://testswarm.com/.

Please do follow up on this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文