What is the issue with updating a cookie from a subpage in PHP?

When updating a cookie from a subpage in PHP, the cookie must be set with the correct path parameter to ensure that it can be accessed and updated across different pages within the same domain. By setting the path parameter to "/", the cookie will be accessible from any page within the domain.

// Update cookie from a subpage
setcookie("cookie_name", "new_value", time() + 3600, "/");