开发者

How to set php cookie counter same url?

$c = $_COOKIE["count"];
$c++;
setcookie("count", $c, time() + 86400, '/test', "localhost");
echo $_COOKIE["count"];
ob_flush();
flush(); 

?>

this is problem when change url exampl开发者_JAVA技巧e

http://www.example.com/test1 count=2
http://www.example.com/test3 count=1
http://www.example.com/test2 count=7

but i would like count only same url ?


It's the way you store the $_COOKIE.

setcookie("count", $c, time() + 86400, '/', 'yoursite.com');

The cookies you were storing will belong to that page only. This will make them accessible to the whole domain by defining a folder and domain.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜