I am willing to count unique visitors once landing on a specific page, I wrote the below code, but the database updates each visit not uniquely,
tried to check the cookie in chrome settings, but did not find TestCookie
Then tried to check from Inspect->Network->Cookies I found my cookie in response cookies ,
Actually, I don't know if this means that it was saved or not, because if it is saved, so why database updates each repeated visit...
<?php include "db.php"; ?>
<?php
if(!isset($_COOKIE['TestCookie'])){
setcookie("TestCookie","yes",60*60*24*320);
mysqli_query($dbConnection,"UPDATE visits SET otal_count = total_count+1");
print_r($_COOKIE);
}else{
return false;
}
?>
Can you try to change third (expires_or_options) paramater of setcookie to
time() + 60*60*24*320
setcookie("TestCookie","yes",time() + 60*60*24*320);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.