I have a website offering a public database which can be searched by a simple form. I am using PDO for the queries.
I tried to Google, but I feel like I am missing the right keyword to help myself.
I would like to limit the searches every user can make to 5 searches per minute. What would be the right way of doing this with low effort? I don't need a high security solution, something to slow everything down a bit would help.
Is there a name for this? What can I search for?
// Create a session variable called something like this after you start the session:
$_SESSION['user_start'] = time();
// Then when they get to submitting the payment, just check whether they're within the 5 minute window
if (time() - $_SESSION['user_start'] < 300) { // 300 seconds = 5 minutes
// they're within the 5 minutes so save the details to the database
} else {
// sorry, you're out of time
unset($_SESSION['user_start']); // and unset any other session vars for this task
}