session timeout in php
Posted: Wed Jan 14, 2009 3:04 am
hi everyone,
needed ur help to know dat how can i timeout a session in php?
i tried with ini_set('session.gc_maxlifetime',2); but dats not helping me out.
alse i tried wid dis code
thanks.
needed ur help to know dat how can i timeout a session in php?
i tried with ini_set('session.gc_maxlifetime',2); but dats not helping me out.
alse i tried wid dis code
Code: Select all
function checkSessionTimeOut(){
// set timeout period in seconds
$inactive=2;
// check to see if $_SESSION['timeout'] is set
if(isset($_SESSION['timeout'])){
$session_life = time() - $_SESSION['timeout'];
if($session_life > $inactive){
return 1;
}else{
$_SESSION['timeout'] = time();
return 2;
}
}else{
$_SESSION['timeout'] = time();
return 3;
}
}