PHP 使用 Cookie 记录用户访问某页面的次数
<无详细内容>
<?php
if (!isset($_COOKIE['visits'])) $_COOKIE['visits'] = 0;
$visits = $_COOKIE['visits'] + 1;
setcookie('visits',$visits,time()+3600*24*365);
?>
<html>
<head>
<title> Title </title>
</head>
<body>
<?php
if ($visits > 1) {
echo("This is visit number $visits.");
} else { // First visit
echo('Welcome to oschina.net! Click here for a tour!');
}
?>
</body>
</html>
精彩图集
精彩文章






