Fix bug that prevents a clean logout

This commit is contained in:
Karsten Heiken
2012-07-17 14:12:37 +02:00
parent f08595a7d5
commit 00dde1197b

View File

@@ -64,9 +64,11 @@ class MY_Session extends CI_Session {
// before continuing, we need to determine if there is any custom data to deal with. // 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) { foreach (array('session_id', 'user_id', 'ip_address', 'user_agent', 'last_activity') as $val) {
if(isset($customUserdata[$val])) {
unset($customUserdata[$val]); unset($customUserdata[$val]);
$cookieUserdata[$val] = $this->userdata[$val]; $cookieUserdata[$val] = $this->userdata[$val];
} }
}
// did we find any custom data? If not, we turn the empty array into a string // did we find any custom data? If not, we turn the empty array into a string
if (count($customUserdata) === 0) { if (count($customUserdata) === 0) {
@@ -76,6 +78,10 @@ class MY_Session extends CI_Session {
$customUserdata = $this->_serialize($customUserdata); $customUserdata = $this->_serialize($customUserdata);
} }
if(!isset($this->userdata['user_id'])) {
$this->userdata['user_id'] = '';
}
// run the update query // run the update query
$this->CI->db->where('session_id', $this->userdata['session_id']); $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)); $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_id' => $this->userdata['user_id'], 'user_data' => $customUserdata));