How to organize the counter to the script?

There is a script.
This script is called when a certain action of the user.
It may be invoked both on the server side using CURL POST and on the side of the user via AJAX.

How to organize the counter for just one visit to the site user through their actions could cause the script not more than 30 times? Is there any solution so the user could not affect a counter — substitution cookies and all that?
June 5th 19 at 21:05
4 answers
June 5th 19 at 21:07
the sessions
Looked. Not working
Is it possible to put a session via POST? - Caterina.Blan commented on June 5th 19 at 21:10
the counter is only authorized. Logged in as that character on the website - he gets a PHPSESSID in the database to record the session, IP and generate a token to paste this token as a parameter to the link on the counter. Well, when you request to check. - tomas.Remp commented on June 5th 19 at 21:13
June 5th 19 at 21:09
Google counter redis
June 5th 19 at 21:11
To do Rate Limit using Redis.
https://redis.io/commands/incr
June 5th 19 at 21:13
Here is an example
<?php ## an Example session.
session_start();
 // If the site has only just gone, reset the counter.
 if (!isset($_SESSION['count'])) $_SESSION['count'] = 0;
 // Increment counter in the session.
 $_SESSION['count'] = $_SESSION['count'] + 1;
?>
<h2>Counter</h2>
In the current session with the browser You opened this page
<?= $_SESSION['count'] ?> time(s).<br>
Close the browser to reset the counter.<br>
<a href="<?= $_SERVER['SCRIPT_NAME'] ?>" target="_blank">Open child browser window</a>.
This is all great, and now read the terms and conditions of the issue) - Caterina.Blan commented on June 5th 19 at 21:16

Find more questions by tags HTTP CookiesSessionsPHP