Firebug 1.2 document.cookie与Web Developer不一致
时间:2020-03-06 14:33:24 来源:igfitidea点击:
我这里有一个URI,其中通过控制台进行的简单document.cookie查询导致显示三个cookie。我也用以下普通代码验证了这一点:
var cookies = document.cookie.split(';'); console.log(cookies.length);
实际上,变量cookie确实是数字3. 另一方面,Web Developer表示总共使用了8个cookie。
我有点困惑,以为哪一个是不正确的。我相信最好的解决方案可能涉及在不受到Firebug影响的情况下仅重复上述代码。但是,我想知道是否有人会建议一个更聪明的替代方法来解密哪个工具给了我不准确的信息。
谢谢大家!
解决方案
原因之一可能是其他5个Cookie是HTTPONLY:
http://msdn.microsoft.com/en-us/library/ms533046.aspx If the HttpOnly attribute is included in the response header, the cookie is still sent when the user browses to a Web site in the valid domain. The cookie cannot be accessed through script in Internet Explorer 6 SP1, even by the Web site that set the cookie in the first place. This means that even if a cross-site scripting bug exists, and the user is tricked into clicking a link that exploits this bug, Windows Internet Explorer does not send the cookie to a third party. The information is safe.
Firefox也遵守此标志(自v2.0.0.5起)。
我敢肯定,Web开发人员工具栏会显示域和子域的Cookie。
因此它将显示Cookie
abc.xyz.com
xyz.com
我们是否在任一域的页面上