Home >Backend Development >PHP Tutorial >Using cookies and JS to implement visit statistics code_PHP tutorial

Using cookies and JS to implement visit statistics code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:44:171017browse

global $count;

$count=1;

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

setcookie("visitcount",1); echo "Welcome to your first visit to the website!";

}

else{

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

setcookie("visitcount",$count); echo "The time you last visited the website was:".$_COOKIE[visittime];

echo "
";

}
echo "The time you visited the website ".$_COOKIE[visitcount]." is:".date("y-m-d H:i:s");

?>

Let’s look at a simple js code to implement visit count statistics

Script description:
Step 1: Add the following code to the area










http://www.bkjia.com/PHPjc/478760.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478760.htmlTechArticleglobal $count; $count=1; if(!isset($_COOKIE["visittime"])){ setcookie("visittime",date("y-m-d H:i:s")); setcookie("visitcount",1); echo "Welcome to your first visit to the website!"; } else{ s...
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