浏览器在传递cookie时与domain有关的策略
来源:互联网 发布:react.js 视频教程 编辑:程序博客网 时间:2024/06/06 08:26
最近在排查一个ie6特定版本(2900.2180 xp sp2 gdr)中才会出现的cookie传递问题,因此查阅了rfc2109.http://tools.ietf.org/html/rfc2109
chrome/ff下向a.b.c.com发送数据,不会提交domain为b.c.com的cookie,但会提交.b.c.com的cookie,因为能提交的cookie必须满足domain-matches条件,如rfc2109所言,x.y.com domain-matches .y.com but not y.com。所以这应该算是ie6特定版本的一个bug自己的实现,它提交了b.c.com的cookie。另一方面,rfc2109规定,An explicitly specified domain must always start with a dot.Domain Defaults to the request-host. (Note that there is no dot at the beginning of request-host.)
为什么默认值选择给出一个不规范的domain而不是主动加个点在最前面呢?
结论:
浏览器在传递cookie时,会传递本域名及其父域(必须以.开头)的所有cookie。即向a.b.c.com发送数据,会带上的cookie有:
a.b.c.com
.b.c.com
.c.com
如果服务器要指定cookie的domain,应该以.开头。
=============追加内容===============
如此文所言:http://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work
RFC 2109 已经被RFC 2965 取代
Although there is the RFC 2965 (Set-Cookie2
, had already obsoleted RFC 2109) that should define the cookie nowadays, most browsers don’t fully support that but just comply to the original specification by Netscape.
There is a distinction between the Domain attribute value and the effective domain: the former is taken from the Set-Cookie
header field and the latter is the interpretation of that attribute value. According to the RFC 2965, the following should apply:
- If the Set-Cookie header field does not have a Domain attribute, the effective domain is the domain of the request.
- If there is a Domain attribute present, its value will be used as effective domain (if the value does not start with a
.
it will be added by the client).
Having the effective domain it must also domain-match the current requested domain for being set; otherwise the cookie will be revised. The same rule applies for choosing the cookies to be sent in a request.
- 浏览器在传递cookie时与domain有关的策略
- 有关Weblogic的domain
- cookie 的domain属性
- cookie的domain实战
- cookie 与浏览器的关系
- 在客户端与服务器端之间传递cookie
- cookie真的只和浏览器有关么?
- 浏览器同源策略及Cookie的作用域
- cookie 的 path 和 domain
- cookie 的 path 和 domain
- 设置cookie的domain属性。
- 设置cookie的domain属性
- cookie的domain参数详解
- cookie 的 path 和 domain
- cookie 的路径和domain
- 了解Cookie与浏览器的关系
- cookie中的path与domain属性详解
- 浅析Cookie中的Path与domain(转)
- Arcengine效率探究之一——属性的读取
- 网络字节转换inet_aton & inet_ntoa & inet_addr和inet_pton & inet_ntop
- [原创]shell对xml操作的脚本
- Apahce启动不起来
- Facebook 的系统架构
- 浏览器在传递cookie时与domain有关的策略
- 由 bind_mismatch 引起的 大量 version_count 问题
- C# ArrayList的使用
- Div布局时注意使用clear属性
- chap3: 程序的机器级表示
- 如何单独编译Android源代码中的模块
- asp.net操作office时报错“检索 COM 类工厂中 CLSID 为 {...} 的组件时失败,原因是出现以下错误: 80070005。”
- Jsp中使用return时应注意
- 正则表达式30分钟入门教程