diff --git a/main/inc/lib/chamilo_session.class.php b/main/inc/lib/chamilo_session.class.php index 561f7f7744..848d93dc81 100755 --- a/main/inc/lib/chamilo_session.class.php +++ b/main/inc/lib/chamilo_session.class.php @@ -86,7 +86,14 @@ class ChamiloSession extends System\Session if (self::session_stored_in_db() && function_exists('session_set_save_handler')) { $handler = new SessionHandler(); - @session_set_save_handler(array(& $handler, 'open'), array(& $handler, 'close'), array(& $handler, 'read'), array(& $handler, 'write'), array(& $handler, 'destroy'), array(& $handler, 'garbage')); + @session_set_save_handler( + array(& $handler, 'open'), + array(& $handler, 'close'), + array(& $handler, 'read'), + array(& $handler, 'write'), + array(& $handler, 'destroy'), + array(& $handler, 'garbage') + ); } /* @@ -120,17 +127,18 @@ class ChamiloSession extends System\Session if ($already_installed) { if (!isset($session['checkChamiloURL'])) { $session['checkChamiloURL'] = api_get_path(WEB_PATH); - } else if ($session['checkChamiloURL'] != api_get_path(WEB_PATH)) { + } elseif ($session['checkChamiloURL'] != api_get_path(WEB_PATH)) { self::clear(); } } - /*if (!$session->has('starttime') || $session->is_valid()) { + /*if (!$session->has('starttime') && !$session->is_expired()) { $session->write('starttime', time()); }*/ - // if the session time has expired, refresh the starttime value, so we're starting to count down from a later time - if ( $session->has('starttime') && $session->is_valid()) { - //error_log('Time expired, cancel session'); + // If the session time has expired, refresh the starttime value, + // so we're starting to count down from a later time + if ( $session->has('starttime') && $session->is_expired()) { + error_log(microtime().' -- '.__LINE__); $session->destroy(); } else { //error_log('Time not expired, extend session for a bit more'); @@ -160,22 +168,12 @@ class ChamiloSession extends System\Session } /** - * Returns true if the session is stalled. I.e. if session end time is - * greater than now. Returns false otherwise. - * @return bool True if the session is expired. False otherwise + * Returns whether the session is expired + * @return bool True if the session is expired, false if it is still valid */ - function is_stalled() + public function is_expired() { - return $this->end_time() >= time(); - } - - /** - * Returns whether the session is not stalled - * @return bool True if the session is still valid, false otherwise - */ - public function is_valid() - { - return !$this->is_stalled(); + return $this->end_time() < time(); } /**