Home > Backend Development > PHP Tutorial > php 利用cookie记录访问次数

php 利用cookie记录访问次数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 08:45:45
Original
1456 people have browsed it
  1. $f_open = fopen("count.txt","r+"); //打开指定的文件
  2. $count = fgets($f_open); //读取文件中的数据
  3. if(empty($_COOKIE['cookie_name'])){ //判断COOKIE的是否存在
  4. setcookie("cookie_name",value,time()+1800); //如果不存在,则创建COOKIE
  5. $count = $count + 1; //将变量$count的值加1
  6. rewind($f_open); //打开指定的文件
  7. fwrite($f_open,$count); //向文件中写入新的数据
  8. fclose($f_open); //关闭文件
  9. }
  10. ?>
复制代码

php, cookie


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