How can you ensure that a cookie is accessible across different pages and directories in PHP?

To ensure that a cookie is accessible across different pages and directories in PHP, you can set the cookie's path parameter to '/' so that it is available throughout the entire domain. By setting the path to '/', the cookie will be accessible across different pages and directories.

// Set a cookie with path set to '/'
setcookie("cookie_name", "cookie_value", time() + 3600, "/");