Are there any best practices for handling cookies in PHP to ensure they work properly across different browsers?

When handling cookies in PHP, it's important to set the cookie parameters correctly to ensure they work properly across different browsers. One common issue is setting the cookie domain to be specific to a subdomain, which can cause the cookie to not be accessible by other subdomains. To solve this, it's recommended to set the cookie domain to the root domain to make it accessible across all subdomains.

// Set cookie with proper domain to make it accessible across all subdomains
setcookie('cookie_name', 'cookie_value', time() + 3600, '/', '.yourdomain.com');