What are best practices for ensuring PHP cookies are properly recognized and accessible in subdomains?

When setting cookies in PHP, it is important to ensure they are accessible across subdomains by setting the cookie domain parameter to the root domain. This can be achieved by explicitly setting the domain parameter when calling setcookie() function in PHP.

setcookie('cookie_name', 'cookie_value', time() + 3600, '/', '.example.com', false, true);