Home >Backend Development >PHP Tutorial >php cookie counter example using cookies to create a counter

php cookie counter example using cookies to create a counter

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:56:17922browse
  1. /**
  2. * cookie counter example
  3. * by bbs.it-home.org
  4. * date: 2013-9-29
  5. */
  6. if (!isset($_COOKIE['visits'])) $_COOKIE['visits'] = 0;
  7. $visits = $_COOKIE[ 'visits'] + 1;
  8. setcookie('visits',$visits,time()+3600*24*365);
  9. ?>
  10. Title <li> <li> <li> <?php <li>if ($visits > 1) {</li> <li> echo("Number of visits: $visits.");</li> <li>} else { // First visit </li> <li> echo('Welcome to the programmer's home, this is your first visit. This section introduces how to implement counters in php cookie.');</li> <li>}</li> <li>?></li> <li> <li>
Copy code


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