I have two webapps WebApp1 and WebApp2 in two different domains.
Cross-site cookies are allowed if:
Set-Cookie
response header includes SameSite=None; Secure
as seen here and hereLet's clarify a "domain" vs a "site"; I always find a quick reminder of "anatomy of a URL" helps me. In this URL https://example.com:8888/examples/index.html
, remember these main parts (got from this paper):
https://
example.com
8888
The "path" part is:/examples/index.html
. Notice the difference between "path" and "site".
path
Servers can set a Path
attribute in the Set-Cookie
, but it doesn't seem security related:
Note that
path
was intended for performance, not security. Web pages having the same origin still can access cookie via document.cookie even though the paths are mismatched.
site
The SameSite attribute, according to web.dev article, can restrict or allow cross-site cookies; but what is a "site"?
It's helpful to understand exactly what 'site' means here. The site is the combination of the domain suffix and the part of the domain just before it. For example, the
www.web.dev
domain is part of theweb.dev
site.
This means what's to the left of web.dev
is a subdomain; yep, www
is the subdomain (but the subdomain is a part of the host)
In this URL https://www.example.com:8888/examples/index.html
, remember these parts:
https://
example.com
8888
www.example.com
example.com
www
Useful links:
(Be careful; I was testing my feature in Chrome Incognito tab; according to my chrome://settings/cookies
; my settings were "Block third party cookies in Incognito", so I can't test Cross-site cookies in Incognito.)