An infinite loop will result in never being able to display the page 
Deleting cookies can't be done literally, so you do what you're doing-- set it to a blank value and to a past time so that the browser clears it automatically.
You also cannot set a cookie for the current page load. It only works after the headers are sent, and therefore won't update while you're running the PHP this time. It'll be reset when the next page loads.
If you want to pretend you've already changed the cookie, then you need to edit the $_COOKIE array. For example, $_COOKIE['name'] = ''; Or unset().
If you want to pretend it can do it in real time and assume that the browser will accept the cookie (most will, but not all) you can do this:
PHP Code:
<?php
function setcookielive($name,$value='',$expire=0,$path='',$domain='',$secure=false,$httponly=false) {
//set a cookie as usual, but ALSO add it to $_COOKIE so the current page load has access
$_COOKIE[$name] = $value;
return setcookie($name,$value,$expire,$path,$domain,$secure,$httponly);
}
?>
Bookmarks