我使用 firebug 手动创建了两个 cookie:
Cookie1=value1; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost; HttpOnly
Cookie2=value2; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost:8080; HttpOnly
唯一的区别是域属性,一个是localhost
一个端口号。
这是我尝试请求时的 HTTP 标头http://localhost:8080/Ex05Cookie/
:
GET /Ex05Cookie/ HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: Cookie1=value1
Connection: keep-alive
Cache-Control: max-age=0
其中标头仅包含 Cookie1,其域为localhost
.
为什么我的 Firefox 不发送 Cookie2 而不是 Cookie1?