I have googled this a lot now and have found conflicting answers. So my question is: how does a browser handle an HTTP cookie that has no domain
and no path
attributes?
For example this response from server:
200 OK https://example.com/a/b (6047ms)
Set-Cookie: x-my-cookie=1.0; Max-Age=86400000; Expires=Sun, 05-Jan-2020 08:30:25 GMT
Should the cookie be included when making requests to https://m.example.com/a/b
?
What about https://example.com/zzzz
?
And https://example.com/a
?
And https://example.com/a/b/c
?
And https://example.com
?
For
Set-Cookie
withoutdomain
attribute, the cookie's domain value is "the origin server". According to RFC6265:With the following exception:
Maybe that's why you found conflicting answers.
For
Set-Cookie
withoutpath
attribute, RFC6265 states that:For your example, the answer would be:
Should the cookie be included when making requests to https://m.example.com/a/b?
No. Because
m.example.com
is not the origin server (example.com
).What about https://example.com/zzzz?
No. Because
/zzz
is not under "directory"/a/b
.And https://example.com/a?
No. Because
/a
is not under "directory"/a/b
.And https://example.com/a/b/c?
Yes. Because
/a/b/c
IS under "directory"/a/b
.And https://example.com?
No. Because
/
is not under "directory"/a/b
.