What are common pitfalls when working with PHP cookies across multiple subdomains?

When working with PHP cookies across multiple subdomains, a common pitfall is that cookies are set to the specific subdomain they were created on by default. To make cookies accessible across all subdomains, you need to set the cookie domain parameter to the root domain. This can be achieved by explicitly setting the domain parameter when setting the cookie.

setcookie('cookie_name', 'cookie_value', time() + 3600, '/', '.yourdomain.com');