I'm trying to make a hit counter
, but this hit counter
update the column counter
every time the page is loaded.
$mread = $conn->prepare("UPDATE bn_publicacao SET counter = counter + 1 WHERE id = :id");
$mread->bindParam(':id', $id, PDO::PARAM_INT);
$mread->execute();
I want it to update the counter
only once per ip/session. How can i do it?
OPTIONAL: Check if session started. Here could be a function(s) that set the session config.
After session has been started and configured, you can use the variables in $_SESSION.
This way it will run the query code only if the $_SESSION['counter'] does not exist.
this is only example of the counter once per session, not the query.