How can PHP cookies be set to be accessible across subdomains?

To set PHP cookies to be accessible across subdomains, you need to specify the domain parameter when setting the cookie. By setting the domain parameter to the root domain, all subdomains will be able to access the cookie.

setcookie("cookie_name", "cookie_value", time() + 3600, "/", ".yourdomain.com", false, true);