Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

problem with session time out

session

  • Please log in to reply
2 replies to this topic

#1 Divya

Divya

    CC Regular

  • Just Joined
  • PipPipPip
  • 32 posts

Posted 01 April 2009 - 09:43 PM

i am doing a quiz website in which i have 4 different category of questions and for each category,there should be a time limit.for that i tried out the following session time out code but still not working.

if(!session_is_registered("session_count")) {
$_SESSION['session_count']=0;
$_SESSION['session_start']=time();
}
$session_timeout = 20; // in sec

$session_duration = time() - $_SESSION['session_start'];
if ($session_duration > $session_timeout) {
header("Location: timeout.php");
}
$_SESSION['session_start']= time();
$_SESSION['session_count']++;


if the time reaches 20 seconds, the page should be redirected to timeout.php which is not working for me.

pls help me.....
  • 0

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 02 April 2009 - 01:46 AM

I'd save the time in the session variable, and compare it next time the user sends the page. session timeout just does nothing more than deletes the cookie and the session variable. better then, to show on your next page that you took too long time to answer...
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 xsonline

xsonline

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 51 posts
  • Programming Language:PHP, JavaScript, PL/SQL

Posted 02 April 2009 - 02:12 PM

An easier way to do this is by doing the folowing:

print('<meta http-equiv="refresh" content="0 URL=timeout.php" />');

hope this helps
  • 0





Also tagged with one or more of these keywords: session

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download