From: Karl DeSaulniers on 16 Apr 2010 14:52 What is the best way to set a user timeout on a session? Say if the user steps away from their computer for say 5 min, and they come back to the page they were on, I want when the user clicks something for the session to kick them off and redirect to login saying their session has timed out. I have this code currently: /*Users timout*/ function getIdle(){ global $database; if($this->isGuest()) { if (!isset($_SESSION['timeout_idle'])) { $_SESSION['timeout_idle'] = time() + GUEST_TIMEOUT; } else { if ($_SESSION['timeout_idle'] < time()) { //destroy session return(true); } else { $_SESSION['timeout_idle'] = time() + GUEST_TIMEOUT; return(false); } } } else { if (!isset($_SESSION['timeout_idle'])) { $_SESSION['timeout_idle'] = time() + USER_TIMEOUT; } else { if ($_SESSION['timeout_idle'] < time()) { //destroy session return(true); } else { $_SESSION['timeout_idle'] = time() + USER_TIMEOUT; return(false); } } } } But it doesn't time anything out.. I could walk away for an hour and come back and go to a link. TIA, Karl DeSaulniers Design Drumm http://designdrumm.com
From: Chris on 18 Apr 2010 20:06 Karl DeSaulniers wrote: > What is the best way to set a user timeout on a session? > Say if the user steps away from their computer for say 5 min, > and they come back to the page they were on, I want when the user clicks > something > for the session to kick them off and redirect to login saying their > session has timed out. > I have this code currently: > > > /*Users timout*/ > function getIdle(){ > global $database; > if($this->isGuest()) { > if (!isset($_SESSION['timeout_idle'])) { > $_SESSION['timeout_idle'] = time() + GUEST_TIMEOUT; > } else { > if ($_SESSION['timeout_idle'] < time()) { > //destroy session > return(true); > } else { > $_SESSION['timeout_idle'] = time() + GUEST_TIMEOUT; > return(false); > } > } > } else { > if (!isset($_SESSION['timeout_idle'])) { > $_SESSION['timeout_idle'] = time() + USER_TIMEOUT; > } else { > if ($_SESSION['timeout_idle'] < time()) { > //destroy session > return(true); > } else { > $_SESSION['timeout_idle'] = time() + USER_TIMEOUT; > return(false); > } > } > } > } > > But it doesn't time anything out.. I could walk away for an hour and > come back and go to a link. > TIA, Firstly - is it getting into this function (yep I ask stupid questions)? Which branch is it taking (guest or user)? What values are USER_TIMEOUT and GUEST_TIMEOUT? -- Postgresql & php tutorials http://www.designmagick.com/
|
Pages: 1 Prev: "Fatal error: Call to undefined function pq_query()" Next: Fwd: Apache log: database shutdown |