コード例 #1
0
 /**
  * Constructor
  * 
  * @param BaseConfig $config
  * @throws \Exception
  */
 public function __construct(BaseConfig $config)
 {
     parent::__construct($config);
     if (empty($this->savePath)) {
         throw new \Exception('Session: No Memcached save path configured.');
     }
     if ($this->matchIP === true) {
         $this->keyPrefix .= $_SERVER['REMOTE_ADDR'] . ':';
     }
     $this->sessionExpiration = $config->sessionExpiration;
 }
コード例 #2
0
 /**
  * Constructor
  * 
  * @param BaseConfig $config
  * @throws \Exception
  */
 public function __construct(BaseConfig $config)
 {
     parent::__construct($config);
     if (empty($this->savePath)) {
         throw new \Exception('Session: No Redis save path configured.');
     } elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\\:(\\d+))?(\\?.+)?#', $this->savePath, $matches)) {
         isset($matches[3]) or $matches[3] = '';
         // Just to avoid undefined index notices below
         $this->savePath = ['host' => $matches[1], 'port' => empty($matches[2]) ? null : $matches[2], 'password' => preg_match('#auth=([^\\s&]+)#', $matches[3], $match) ? $match[1] : null, 'database' => preg_match('#database=(\\d+)#', $matches[3], $match) ? (int) $match[1] : null, 'timeout' => preg_match('#timeout=(\\d+\\.\\d+)#', $matches[3], $match) ? (double) $match[1] : null];
         preg_match('#prefix=([^\\s&]+)#', $matches[3], $match) && ($this->keyPrefix = $match[1]);
     } else {
         throw new \Exception('Session: Invalid Redis save path format: ' . $this->savePath);
     }
     if ($this->matchIP === true) {
         $this->keyPrefix .= $_SERVER['REMOTE_ADDR'] . ':';
     }
     $this->sessionExpiration = $config->sessionExpiration;
 }