Home >php教程 >php手册 >利用cookie 实现访问次数统计代码

利用cookie 实现访问次数统计代码

WBOY
WBOYOriginal
2016-06-13 10:03:41900browse

本教程举了两个实例说明利用cookie实现访问次数统计的代码,包括有php教程 js 两种方法

global $count;

$count=1;

if(!isset($_COOKIE["visittime"])){ setcookie("visittime",date("y-m-d H:i:s"));

setcookie("visitcount",1); echo "欢迎你第一次访问网站!";

}

else{

setcookie("visittime",date("y-m-d,H:i:s"),time()+60); $count=$_COOKIE['visitcount']+1;

setcookie("visitcount",$count); echo "你上次访问网站的时间为:".$_COOKIE['visittime'];

echo "
";

}

echo "你第".$_COOKIE['visitcount']."访问网站的时间为:".date("y-m-d H:i:s");

?>

下面看个简单的js实现访问次数统计代码

脚本说明:
第一步:把如下代码加入

区域中






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