From 00dde1197b2ed05c7f7ce99d6706ab48f60ee082 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Tue, 17 Jul 2012 14:12:37 +0200 Subject: [PATCH] Fix bug that prevents a clean logout --- application/libraries/MY_Session.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php index 040a075..49b503a 100644 --- a/application/libraries/MY_Session.php +++ b/application/libraries/MY_Session.php @@ -64,8 +64,10 @@ class MY_Session extends CI_Session { // before continuing, we need to determine if there is any custom data to deal with. foreach (array('session_id', 'user_id', 'ip_address', 'user_agent', 'last_activity') as $val) { - unset($customUserdata[$val]); - $cookieUserdata[$val] = $this->userdata[$val]; + if(isset($customUserdata[$val])) { + unset($customUserdata[$val]); + $cookieUserdata[$val] = $this->userdata[$val]; + } } // did we find any custom data? If not, we turn the empty array into a string @@ -76,6 +78,10 @@ class MY_Session extends CI_Session { $customUserdata = $this->_serialize($customUserdata); } + if(!isset($this->userdata['user_id'])) { + $this->userdata['user_id'] = ''; + } + // run the update query $this->CI->db->where('session_id', $this->userdata['session_id']); $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_id' => $this->userdata['user_id'], 'user_data' => $customUserdata));