I've searched a lot and didn't found a simply answer, all i need is dont allow user to run the same php script too fast, like if he sent the form, i need to block the same form to be runned again for 10 seconds.
I tried using:
if(isset($_SESSION['var']){
exit;
}
and setting the var on the start of the script and then unsetting it on script finish, but it will only disallow him to run the script while it's currently running, is there any way to do this?
You can use Timeout to prevent user run script to fast , But php use Session to store Timeout like this :
session_start(); //At the beginning of the PHP file
define("TIMEOUT", 10); //10 sec
//Check timeout
if (isset($_SESSION['expire'])) {
if ($_SESSION['expire']-time()>TIMEOUT) {
unset($_SESSION['expire']);
}
}
//Allow to do submit after 10 sec
if (!isset($_SESSION['expire'])) {
$_SESSION['expire']=time();
//Your submit code
}