Home  >  Article  >  php教程  >  30秒内对页面的访问次数【COOKIE】

30秒内对页面的访问次数【COOKIE】

PHP中文网
PHP中文网Original
2016-05-25 17:06:531345browse

代码

<?php
//Calculate 60 days in the future 
//seconds * minutes * hours * days + current time 
$intime = 30 + time(); // 30秒缓存
if(isset($_COOKIE[&#39;lastVisit&#39;])) {
$visit = $_COOKIE[&#39;lastVisit&#39;] + 1; 
}
else {
$visit = "0";
}
setcookie("lastVisit",$visit, $intime);
echo "Your last visit was - ". $visit; 
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn