Are HTTP cookies port specific?

前端 未结 8 1865
傲寒
傲寒 2020-11-22 04:14

I have two HTTP services running on one machine. I just want to know if they share their cookies or whether the browser distinguishes between the two server sockets.

8条回答
  •  隐瞒了意图╮
    2020-11-22 05:05

    According to RFC2965 3.3.1 (which might or might not be followed by browsers), unless the port is explicitly specified via the port parameter of the Set-Cookie header, cookies might or might not be sent to any port.

    Google's Browser Security Handbook says: by default, cookie scope is limited to all URLs on the current host name - and not bound to port or protocol information. and some lines later There is no way to limit cookies to a single DNS name only [...] likewise, there is no way to limit them to a specific port. (Also, keep in mind, that IE does not factor port numbers into its same-origin policy at all.)

    So it does not seem to be safe to rely on any well-defined behavior here.

提交回复
热议问题