<?php
function 客人ip()
{
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
if (isset($_COOKIE["到訪"])){
setcookie("PHPSESSID",$value, time()+3600*24);
$count = $_COOKIE["到訪"] + 1;
}else{
$count = 1;
}
$flag = setcookie("到訪", $count, time() + 180);
print('PHPSESSID:'.$_COOKIE["PHPSESSID"]);
echo '<br>';
print('IP位置:'.客人ip());
?>
<html>
<head><title>COOKIE + 到訪次數 + 來訪地址</title></head>
<body>
<?php
print('<p>第'.$count.'次到訪</p>');
?>
</body>
</html>