Deleting Cookies in PHP
PHP does not have a built-in mechanism for deleting cookies. Therefore, cookies are deleted using a clever method - by setting the cookie's 'death' time to the current moment:
<?php
setcookie('test', '', time());
?>
Deleting a cookie will lead to a change in $_COOKIE
only after the page is reloaded:
<?php
setcookie('test', '', time());
var_dump($_COOKIE['test']); // will output the cookie value the first time
?>
Delete some cookie. Refresh the page and make sure it has been deleted.