<?php
$cnt_visit = 0;
if(isset($_COOKIE["cnt_visit"]))
$cnt_visit = $_COOKIE["cnt_visit"];
$cnt_visit++;
if(isset($_COOKIE["last_visit"]))
$last_visit = $_COOKIE["last_visit"];
setcookie("cnt_visit",$cnt_visit,0x7FFFFFFF);
setcookie("last_visit",date('d-m-Y H:i:s'),0x7FFFFFFF);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PHP</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<h1>Последний визит</h1>
<?php
if ($cnt_visit==1)
echo "Добро пожаловать!";
else{
echo "Вы пришли $cnt_visit раз.<br>Последний визит: $last_visit.";
}
?>
</body>
</html>