How to set php access time limit

I am trying to set a restriction on a PHP script. For example, the index.phpuser enters the code / password and is redirected to content.php there, he can use my script to say so final.php.

I need something like this after using my script if he wants to use it again. He needs to wait 5 minutes or so.

those. the user should not have access to final.php(from content.php), and instead he should receive an error message, please wait 5 minutes.

I am new to PHP, so please help me out.

+4
source share
3 answers

content.php -

<?php 
session_start();
include('final.php');
?>

hows final.php : -

<?php
if(!isset($_SESSION)) session_start();
$currentTime=round(microtime(true));
$UserRegTime=(isset($_SESSION["last_access_time"]))?$_SESSION["last_access_time"]:'0';
if(($currentTime-$UserRegTime)>300)
{
//Write ACCESS Content Code Here
echo "Granted";
$_SESSION['last_access_time']=$currentTime;
}
else
{
echo "Please Wait For ".(300-($currentTime-$UserRegTime))." Seconds To Gain Access";
}
?>
+2

. 5 , .

:

  • Et cetera

, - . , , - , Google . , Stackoverflow, .

+4

You can use $_SESSION. When the user first navigates to final.php, you should save the current timestamp in a variable $_SESSION, and next time you will check if the difference between this variable and the current timestamp is more than 5 minutes.

0
source

All Articles