Using cookies to implement visit statistics code_PHP tutorial

WBOY
Release: 2016-07-13 16:59:09
Original
994 people have browsed it

This tutorial gives two examples to illustrate the code of using cookies to implement visit count statistics, including two methods of php tutorial and js

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 "Your first ".$_COOKIE['visitcount']." The time you visited the website 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







www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631336.htmlTechArticle本教程举了两个实例说明利用cookie实现访问次数统计的代码,包括有php教程 js 两种方法 ?php global $count; $count=1; if(!isset($_COOKIE[visittime])){ s...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template