Are there any best practices for handling cookies in PHP to ensure they can be accessed successfully?

When handling cookies in PHP, it is important to set the correct path and domain parameters to ensure they can be accessed successfully across different pages or subdomains. Additionally, it is recommended to set the secure and HttpOnly flags for enhanced security.

// Set a cookie with correct parameters
setcookie("my_cookie", "cookie_value", time() + 3600, "/", "example.com", true, true);