What is the significance of specifying a path when setting cookies in PHP, and how does it affect cookie accessibility?

Specifying a path when setting cookies in PHP allows you to control the accessibility of the cookie within different directories on your website. If you set a specific path for a cookie, the cookie will only be accessible within that path and its subdirectories. This can be useful for restricting access to certain cookies based on the location of the user within your website.

// Set a cookie with a specific path
setcookie("user", "John Doe", time() + 3600, "/admin");