Add a cookie on the user's behalf for each article that has been viewed. Is it reasonable?
Recently, one of the functions of the fuss is to count the number of views (traffic) of the current article
My article address is news.php?id=123.
Find a way online
$gid = $_get["id";
if ($_cookie["user"]! = "Oldguest") {
$hits _now = $row ["hits"]+1;
$pdo->exec ("UPDATE ' Gamedb_game ' SET ' hits ' = ' $hits _now ' WHERE ' id ' = ' $gid '");
}
In this case, the same browser will refresh the second time, will not repeat the increase in the number of views
But I think not, go to other articles, even if the first time to browse, do not increase the view
What do I think?
$gid = $_get["id";
if ($_cookie["user"]! = "Oldguest_$gid") {
$hits _now = $row ["hits"]+1;
$pdo->exec ("UPDATE ' Gamedb_game ' SET ' hits ' = ' $hits _now ' WHERE ' id ' = ' $gid '");
}
change the oldguest to Oldguest_$gid there is an article ID added to the back, there is a uniqueness of it?
but does this, to some extent, have a bad response to the user's browser?
Or does the other CMS do it?
If you want to write SQL to match whether it's the first time, it's too complicated.
Think of only cookies
This way to my own host, as well as to the user, what will happen?
------Solution--------------------
View count increase refresh once more no problem yes,
If you really want to use your method do not let it see it can be put into the cache, set a time to draw, specify the time to take one, many sites are doing so.
Your method can try to put the article ID into the array, and then sequence the words, save the cookie to try.
------Solution--------------------
Record the title of the article viewed by the user to a cookie, and the next time the user opens the page to view the article, there will be a record that was last viewed.
This is a bit like you do shopping site browsing products, the next time you go to see, there is your last browsing record.