Use cookies to calculate the number of visits. code _ PHP Tutorial

Source: Internet
Author: User
Use cookies to calculate the number of visits. This tutorial provides two examples to illustrate how to use cookies to calculate the number of visits. Are there two methods for php Tutorial JavaScript? Phpglobal $ count; $ count1; if (! Isset ($ _ COOKIE [visittime]) {s this tutorial provides two examples to illustrate how to use cookie to calculate the number of visits, including two methods: php Tutorial js

Global $ count;

$ Count = 1;

If (! Isset ($ _ COOKIE ["visittime"]) {setcookie ("visittime", date ("y-m-d H: I: s "));

Setcookie ("visitcount", 1); echo "welcome to visit your website for the first time! ";

}

Else {

Setcookie ("visittime", date ("y-m-d, H: I: s"), time () + 60 ); $ count = $ _ COOKIE ['visitcount'] + 1;

Setcookie ("visitcount", $ count); echo "the last time you visited the website:". $ _ COOKIE ['visittime'];

Echo"
";

}

Echo "Your Number". $ _ COOKIE ['visitcount']. "the website access time is:". date ("y-m-d H: I: s ");

?>

The following is a simple js code for calculating the number of accesses.

Script Description:
Step 1: Add the following codeRegion


Two methods for using JavaScript? Php global $ count; $ count = 1; if (! Isset ($ _ COOKIE [visittime]) {s...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.