I have a laravel app on a parent domain. SESSION_DOMAIN is set to .domain.com because I want the cookies to be shared with another subdomain first.domain.com.
I now want to publish another app at second.domain.com which is separate from domain.com and first.domain.com.
The SESSION_DOMAIN for this second app is correctly set to second.domain.com.
Everytime I try to login via sanctum I get an error CSRF token mismatch.
I'm pretty certain this is due to the multiple cookies on multiple domains since if I clear my cookies for the parent domain.com or use incognito mode or another browser then the issue goes away.
The issue only exists when both .domain.com and second.domain.com have a XSRF-TOKEN cookie token set.
Everything else seems to work fine, presumably because the other cookie Laravel uses called _session is prefixed by the app name and therefore unique.
Where as the XSRF-TOKEN is always called XSRF-TOKEN.
How can I set it up so that my parent domain can share cookies with first.domain.com but doesn't interfere with second.domain.com?
domainportion out of the Set-Cookie header to begin with (developer.mozilla.org/en-US/docs/Web/HTTP/Headers/…: "If omitted, this attribute defaults to the host of the current document URL, not including subdomains.") - but I am not sure if Laravel allows for that via the configuration, plus you would have to explicitly set a second cookie valid forfirst.domain.comas well here then.second.domain.comto use a different session name.