我正在实施一个PHP页面计数器,每次用户访问此页面后,跟踪浏览器关闭.我正在检查cookie是否设置,如果是.然后我增加它并重置其值.但我遇到的问题是柜台总是在两个,为什么呢?
<html> <head> <title>Count Page Access</title> </head> <body> <?PHP if (!isset($_COOKIE['count'])) { ?> Welcome! This is the first time you have viewed this page. <?PHP $cookie = 1; setcookie("count",$cookie); } else { $cookie = $_COOKIE['count']++; setcookie("count",$cookie); ?> You have viewed this page <?= $_COOKIE['count'] ?> times. <?PHP }// end else ?> </body> </html>
编辑:感谢大家,我做了增量的事情,让它工作