summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-01-19 01:29:49 +0100
committerAndrey Andreev <narf@devilix.net>2015-01-19 01:29:49 +0100
commit5231d3267269d7fd8e84b1faf637cef3ba2f1dec (patch)
tree283fd2ed73b58719f8fd523bec56452aa7049074 /system/libraries/Session/drivers
parent74009756ea938c2bde8147cb757d9a4835b78e6d (diff)
feature/session (#3073): Only PostgreSQL data should be base64-encoded
Diffstat (limited to 'system/libraries/Session/drivers')
-rw-r--r--system/libraries/Session/drivers/Session_database_driver.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/system/libraries/Session/drivers/Session_database_driver.php b/system/libraries/Session/drivers/Session_database_driver.php
index 46780b0db..e27c96595 100644
--- a/system/libraries/Session/drivers/Session_database_driver.php
+++ b/system/libraries/Session/drivers/Session_database_driver.php
@@ -178,7 +178,14 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
if ($this->_row_exists === FALSE)
{
- if ($this->_db->insert($this->_config['save_path'], array('id' => $session_id, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'timestamp' => time(), 'data' => base64_encode($session_data))))
+ $insert_data = array(
+ 'id' => $session_id,
+ 'ip_address' => $_SERVER['REMOTE_ADDR'],
+ 'timestamp' => time(),
+ 'data' => ($this->_platform === 'postgre' ? base64_encode($session_data) : $session_data)
+ );
+
+ if ($this->_db->insert($this->_config['save_path'], $insert_data))
{
$this->_fingerprint = md5($session_data);
return $this->_row_exists = TRUE;
@@ -193,9 +200,13 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
}
- $update_data = ($this->_fingerprint === md5($session_data))
- ? array('timestamp' => time())
- : array('timestamp' => time(), 'data' => base64_encode($session_data));
+ $update_data = array('timestamp' => $time);
+ if ($this->_fingerprint !== md5($session_data))
+ {
+ $update_data['data'] = ($this->_platform === 'postgre')
+ ? base64_encode($session_data)
+ : $session_data;
+ }
if ($this->_db->update($this->_config['save_path'], $update_data))
{