I'm trying to do this counter for cookies. The cookies give the right values when I visit the site more than once but for first visit, it always tell me that the cookies(both) are not set. I'm new at PHP so I'm not sure if I missed something. The cookies are set before html tags.
setcookie("user", isset($_COOKIE["user"])? ++$_COOKIE["user"] : 1);
setcookie("date", date("d/m/y h:i:s"));
$count = $_COOKIE["user"];
---------------------------------
<body>
<p><?php
if( $count == 1)
echo "Welcome! You're new here.";
else
echo "Hello, you have visited " .$_COOKIE["user"]. " times.";
echo "<br/>";
echo "Your last visit was ".$_COOKIE["date"];
?></p>
</body>