What are some potential pitfalls when setting and deleting cookies in PHP?

One potential pitfall when setting and deleting cookies in PHP is not specifying the correct path for the cookie. If the path is not set correctly, the cookie may not be accessible on certain pages of the website. To solve this issue, always specify the correct path when setting or deleting cookies.

// Setting a cookie with a specific path
setcookie("example_cookie", "value", time() + 3600, "/path/to/cookie");

// Deleting a cookie with a specific path
setcookie("example_cookie", "", time() - 3600, "/path/to/cookie");