How can a cookie be destroyed (logged out)?
A cookie can be destroyed by setting its expiration time to a past date. This will cause the browser to remove the cookie from its storage, effectively logging the user out.
// Set the cookie's expiration time to a past date to destroy it
setcookie("user_id", "", time() - 3600, "/");