为什么我的Cookie偶尔包含JSON格式不正确 [英] Why are my cookies containing JSON occasionally malformed
问题描述
我们正在使用Cookie来获取有关网站访问者的一些非敏感便利数据.我们发出三个值: 1)创建日期(以滴答为单位), 2)用户数据,JSON序列化, 3)验证哈希
We're using a cookie for some non-sensitive convenience data about our site visitors. We emit three values: 1) creation date (in ticks), 2) user data, JSON serialized, 3) validation hash
我们看到只有一半cookie的大量请求.它们包含完整的日期和截断的用户数据,例如{"Foo":false,"Bar":0
We're seeing a fair number of requests coming in with only half a cookie. They contain the full date and truncated user data, something like {"Foo":false,"Bar":0
这是一个高流量站点,不良cookie的数量看起来为每分钟1-3个(每分钟81000个页面请求中).
This is a high-volume site, and the number of bad cookies looks to be about 1-3 per minute (out of 8-10 thousand page requests per minute).
有人经历过类似的经历吗?我想知道我们是否有一个不喜欢JSON的浏览器,或者某些浏览器将标头截断,或者是否存在JSON序列化程序错误.我们正在.NET 3.5中使用JavaScriptSerializer.
Anyone experience anything similar? I'm wondering if we have a browser that doesn't like the JSON, or maybe the header is getting truncated by some browsers, or maybe there's a JSON serializer bug. We're using the JavaScriptSerializer in .NET 3.5.
推荐答案
未编码的嵌入式逗号和填充满的cookie是此行为的典型原因
unencoded embedded commas and over stuffed cookies are the typical causes of this behavior
这篇关于为什么我的Cookie偶尔包含JSON格式不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!