Here is the solution
NOTE: you shudnt send any headers or data to browser before setting cookies so when it reads the if statement if cookie is not set for the first time it returns "cookie does not exist!" to browsers so headers are already sent. so replace the code like this. AND refresh the page twice u can see "cookie exists".
<?
setcookie("testcookie", "cookie", time()+60);
if(isset($_COOKIE['testcookie']))
echo "cookie exists";
else
echo "cookie does not exist!";
?>