This topic is locked

Limited time process

12/1/2011 2:16:23 PM
PHPRunner General questions
N
notuo author

Hi again.
For a system, in some pages the user has an specific time to do the whole process (the process involves some forms, reading information, answering questions and choose options and go on.
Do you know a way to real check for this elapsed time in order to:
Prevent the user before is expired

Display the remaining time in the screen

If the last send is used after the expiration time occurred the discard that input
The main issue is: What if the electric power went off. Then I don't have to start all over but continue from the last point and of course I had to keep time in order the user not exceed their total time.
Thanks in advance for any comments on this.

C
cgphp 12/2/2011

SESSION vars can help you to achieve this:

  1. After a successful login set a session var for the start time and a session var for the time limit

$_SESSION['start_time'] = time();

$_SESSION['time_limit'] = 900; //15 minutes



2. Before every sub-process (in the "Before record added" event for example) check if the time limit has been reached

if((time() - $_SESSION['start_time']) >= $_SESSION['time_limit'])

{

//block user action

}
N
notuo author 12/2/2011

Thanks Christian. I'll take a look at this.