I'm trying to set a cookie using PHP on a subdomain (api.example.com) and read it on the main domain (example.com)
My setcookie looks like this:
setcookie("user-hash", $userHash, $expiry, "/", $domain, true, true);
Where $domain
has been a few different things over the course of the day e.g. "example.com", ".example.com", "" and nothing seems to work.
I'm now wondering if it is something else, or if is even possible? I've seen plenty of people posting examples of how to set/read a cookie on the main domain but not much the other way around.
My cookies worked fine before I moved this script to the subdomain.