I have some domain example.com. User logs in from the example.com and I want to set cookies for subdomains foo.example.com, bar.example.com etc. When I try to set it like such:
setcookie($cookie_name, $token, $expires, '/', '.example.com');
I got an error "Set-Cookie was blocked because its Domain attribute was invalid with regards to the current host url" in my Chrome 92.
When I try to make it with samesite=none:
setcookie($cookie_name, $token, [
'expires' => $expires,
'path' => '/',
'domain' => '.example.com',
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);
I have the same error in my Chrome 92.
I didn't test it with https yet. Is it possible to set cookie for subdomain for HTTP?