From d868007dac92c35cc2ca3c5bd196470e2da4a0f8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 27 Aug 2004 13:17:25 +0000 Subject: [PATCH] fixed some of our sessions problems: - [ 1015846 ] Registering session MySQL query error - handlich of timed out sessions for php4 sessions was wrong ==> I can't reproduce any more sessions probs, either with db nor php4 sessions --- phpgwapi/inc/class.sessions.inc.php | 2 +- phpgwapi/inc/class.sessions_db.inc.php | 2 +- phpgwapi/inc/class.sessions_php4.inc.php | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index f190742ea9..7455ec5a93 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -278,7 +278,7 @@ */ if ($session['session_dla'] <= (time() - $GLOBALS['phpgw_info']['server']['sessions_timeout'])) { - $this->clean_sessions(); + $this->destroy($sessionid,$kp3); return False; } diff --git a/phpgwapi/inc/class.sessions_db.inc.php b/phpgwapi/inc/class.sessions_db.inc.php index b06b7347d9..e708cce67c 100644 --- a/phpgwapi/inc/class.sessions_db.inc.php +++ b/phpgwapi/inc/class.sessions_db.inc.php @@ -59,7 +59,7 @@ function register_session($login,$user_ip,$now,$session_flags) { - $GLOBALS['phpgw']->db->query("DELETE FROM phpgw_sessions WHERE session_id='$this->sessionsid'",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("DELETE FROM phpgw_sessions WHERE session_id='$this->sessionid'",__LINE__,__FILE__); $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_sessions VALUES ('" . $this->sessionid . "','".$login."','" . $user_ip . "','" diff --git a/phpgwapi/inc/class.sessions_php4.inc.php b/phpgwapi/inc/class.sessions_php4.inc.php index a835a97840..00c14d3b27 100644 --- a/phpgwapi/inc/class.sessions_php4.inc.php +++ b/phpgwapi/inc/class.sessions_php4.inc.php @@ -105,7 +105,7 @@ function destroy($sessionid, $kp3) { - if (! $sessionid && $kp3) + if (!$sessionid && $kp3) { return False; } @@ -115,8 +115,8 @@ // Only do the following, if where working with the current user if ($sessionid == $GLOBALS['phpgw_info']['user']['sessionid']) { - $this->clean_sessions(); session_unset(); + //echo "

sessions_php4::destroy: session_destroy() returned ".(session_destroy() ? 'True' : 'False')."

\n"; session_destroy(); if ($GLOBALS['phpgw_info']['server']['usecookies']) { @@ -235,9 +235,12 @@ { continue; // happens if webserver runs multiple user-ids } - $fd = fopen ($path . '/' . $file,'r'); - $session = fread ($fd, filesize ($path . '/' . $file)); - fclose ($fd); + $session = ''; + if (($fd = fopen ($path . '/' . $file,'r'))) + { + $session = ($size = filesize ($path . '/' . $file)) ? fread ($fd, $size) : 0; + fclose ($fd); + } if (substr($session,0,14) != 'phpgw_session|') { continue;