summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/drivers/Session_redis_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-10-06 00:50:14 +0200
committerAndrey Andreev <narf@devilix.net>2014-10-06 00:50:14 +0200
commitdfb39bec5faf77e806e55f3ee9d2138e57d55010 (patch)
tree8060a4e8f7a28d230e689880bba022cd1ba081d4 /system/libraries/Session/drivers/Session_redis_driver.php
parent4a485a73d64a8bebc7625aabc5fdc361d5e7dc56 (diff)
feature/session (#3073): Refactor configuration & fix cookie expiry times
Diffstat (limited to 'system/libraries/Session/drivers/Session_redis_driver.php')
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php31
1 files changed, 12 insertions, 19 deletions
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 6d8044da1..ef18defe2 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -38,13 +38,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class CI_Session_redis_driver extends CI_Session_driver implements SessionHandlerInterface {
/**
- * Save path
- *
- * @var string
- */
- protected $_save_path;
-
- /**
* phpRedis instance
*
* @var resource
@@ -77,14 +70,14 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
parent::__construct($params);
- if (empty($this->_save_path))
+ if (empty($this->_config['save_path']))
{
log_message('error', 'Session: No Redis save path configured.');
}
- elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->_save_path, $matches))
+ elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->_config['save_path'], $matches))
{
isset($matches[3]) OR $matches[3] = ''; // Just to avoid undefined index notices below
- $this->_save_path = array(
+ $this->_config['save_path'] = array(
'host' => $matches[1],
'port' => empty($matches[2]) ? NULL : $matches[2],
'password' => preg_match('#auth=([^\s&]+)#', $matches[3], $match) ? $match[1] : NULL,
@@ -96,10 +89,10 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
}
else
{
- log_message('error', 'Session: Invalid Redis save path format: '.$this->_save_path);
+ log_message('error', 'Session: Invalid Redis save path format: '.$this->_config['save_path']);
}
- if ($this->_match_ip === TRUE)
+ if ($this->_config['match_ip'] === TRUE)
{
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
}
@@ -109,23 +102,23 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
public function open($save_path, $name)
{
- if (empty($this->_save_path))
+ if (empty($this->_config['save_path']))
{
return FALSE;
}
$redis = new Redis();
- if ( ! $redis->connect($this->_save_path['host'], $this->_save_path['port'], $this->_save_path['timeout']))
+ if ( ! $redis->connect($this->_config['save_path']['host'], $this->_config['save_path']['port'], $this->_config['save_path']['timeout']))
{
log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
}
- elseif (isset($this->_save_path['password']) && ! $redis->auth($this->_save_path['password']))
+ elseif (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
{
log_message('error', 'Session: Unable to authenticate to Redis instance.');
}
- elseif (isset($this->_save_path['database']) && ! $redis->select($this->_save_path['database']))
+ elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
{
- log_message('error', 'Session: Unable to select Redis database with index '.$this->_save_path['database']);
+ log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
}
else
{
@@ -157,7 +150,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
$this->_redis->setTimeout($this->_lock_key, 5);
if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
{
- if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_expiration))
+ if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
{
$this->_fingerprint = $fingerprint;
return TRUE;
@@ -166,7 +159,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return FALSE;
}
- return $this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_expiration);
+ return $this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']);
}
return FALSE;