global $CFG;
if (isset($CFG->session_timeout)) {
- $this->timeout = $CFG->session_timeout * 60;
+ $this->settings['timeout'] = $CFG->session_timeout * 60;
} else {
- $this->timeout = 20 * 60;
+ $this->settings['timeout'] = 20 * 60;
}
- if (ini_get('session.gc_maxlifetime') != $this->timeout)
- ini_set('session.gc_maxlifetime', $this->timeout);
- if (ini_get('session.cookie_lifetime') != $this->timeout)
- ini_set('session.cookie_lifetime', $this->timeout);
+ if (ini_get('session.gc_maxlifetime') != $this->settings['timeout'])
+ ini_set('session.gc_maxlifetime', $this->settings['timeout']);
+ if (ini_get('session.cookie_lifetime') != $this->settings['timeout'])
+ ini_set('session.cookie_lifetime', $this->settings['timeout']);
+
+ $_SESSION['settings'] = $this->settings;
session_start();
}
private function checkSession() {
global $CFG;
+ if ('' == session_id()) {
+ $this->startSession();
+ }
+
$time = $_SERVER['REQUEST_TIME'];
if (isset($_SESSION['LAST_ACTIVITY']) &&
($time - $_SESSION['LAST_ACTIVITY']) >= $this->settings['timeout']) {
}
public function logout() {
- $_SESSION = array();
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params['path'], $params['domain'],
$params['secure'], $params['httponly']);
}
- session_unset();
- session_destroy();
+
+ if ('' != session_id()) {
+ $_SESSION = array();
+ session_unset();
+ session_destroy();
+ }
$this->settings = array();
}
$this->startSession();
}
+ $this->checkSession();
+
if (isset($this->settings['user'])) {
if ($this->settings['user'] != null) {
$loggedIn = true;
}
if ($loggedIn == false) {
- echo '$this->user: '.$this->user.' $_SESSION[\'user\']: '.$_SESSION['user'];
+ echo '$this->settings: '.var_export($this->settings, true);
echo 'R_TIME: '.date('c', $_SERVER['REQUEST_TIME']).' L_ACT: '.date('c', $_SESSION['LAST_ACTIVITY']);
//exit;
}