Reputation: 27
Wondering what would be the most efficient way to do the following.
Game play. Player can train and every 8 mins a captcha verify kicks in to stop them from using bots/scripts to auto train.
However thats still a lengthy amount of time. So thinking about making it per 100 clicks the verify enables.
Now I could do this simply in the database and record the user clicks and then when they reach the limit reset the captcha. But this seems excessive use of resources.
Would there be another way to do it sessions perhaps?
Upvotes: 1
Views: 177
Reputation: 6186
This is not possible using pure PHP since PHP is a server side code and has no real concept of the term 'clicks'. The one caveat to this being if a 'click' always triggers a server response (i.e. they are clicking on links). If they are not triggering a server response then you will have to use some form of client side coding such as JavaScript. If they are then the most viable solutions are using sessions or simply updating the database directly on each click. At the top of the page that is loaded you could simply use something along the lines of...
<?php
session_start();
if ($_SESSION['clicks']++ == 100) {
// trigger captcha
$_SESSION['clicks'] == 0;
}
Upvotes: 1