What is the correct syntax for deleting a cookie in PHP and what potential pitfalls should be considered?

To delete a cookie in PHP, you need to set the cookie with an expiration date in the past. This will prompt the browser to remove the cookie. It's important to note that the cookie must be unset before any output is sent to the browser to avoid any headers already being sent errors.

// Unset the cookie by setting its expiration date to the past
setcookie("cookie_name", "", time() - 3600, "/");