/** * Constructor * * @param null|array $options * @throws Phalcon\Session\Exception */ public function __construct($options = null) { if (is_array($options)) { if (!isset($options["host"])) { throw new \Phalcon\Session\Exception("No session host given in options"); } if (!isset($options["port"])) { $options["port"] = self::DEFAULT_OPTION_PORT; } if (!isset($options["lifetime"])) { $options["lifetime"] = self::DEFAULT_OPTION_LIFETIME; } if (!isset($options["persistent"])) { $options["persistent"] = self::DEFAULT_OPTION_PERSISTENT; } if (!isset($options["prefix"])) { $options["prefix"] = self::DEFAULT_OPTION_PREFIX; } if (isset($options['name'])) { ini_set('session.name', $options['name']); } if (isset($options['lifetime'])) { ini_set('session.gc_maxlifetime', $options['lifetime']); } if (isset($options['cookie_lifetime'])) { ini_set('session.cookie_lifetime', $options['cookie_lifetime']); } } else { throw new \Phalcon\Session\Exception("No configuration given"); } session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); parent::__construct($options); }
/** * Phalcon\Session\Adapter\Mongo constructor * * @param array $options */ public function __construct($options = null) { if (!isset($options['collection'])) { throw new Exception("The parameter 'collection' is required"); } session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); parent::__construct($options); }
/** * Phalcon\Session\Adapter\Redis constructor * * @param array $options */ public function __construct($options = null) { if (!isset($options['path'])) { throw new Exception("The parameter 'save_path' is required"); } ini_set('session.save_handler', 'redis'); ini_set('session.save_path', $options['path']); parent::__construct($options); }
public function __construct($options = null) { if (isset($options['cycle_time'])) { $this->cycle_time = intval($options['cycle_time']); } session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); register_shutdown_function('session_write_close'); parent::__construct($options); }
/** * Removes a property from the internal bag * *<code> * $user->remove('name'); *</code> * * @param string $property * @return boolean * @throws Exception */ public function remove($property) { if (is_string($property) === false) { throw new Exception('Invalid parameter type.'); } if ($this->_initialized === false) { $this->initialize(); } if (isset($this->_data[$property]) === true) { unset($this->_data[$property]); $this->_session->set($this->_name, $this->_data); return true; } return false; }
/** * Rudder\Session\Adapter\Redis constructor */ public function __construct($options = []) { if (!isset($options['host'])) { $options["host"] = "127.0.0.1"; } if (!isset($options['port'])) { $options["port"] = 6379; } if (!isset($options['persistent'])) { $options["persistent"] = false; } if (isset($options['lifetime'])) { $this->_lifetime = $options['lifetime']; } $this->_redis = new RedisCache(new FrontendNone(["lifetime" => $this->_lifetime]), $options); session_set_save_handler([$this, "open"], [$this, "close"], [$this, "read"], [$this, "write"], [$this, "destroy"], [$this, "gc"]); parent::__construct($options); }
/** * Phalcon\Session\Adapter\Redis constructor * * @param array $options * * @throws Exception */ public function __construct($options = null) { if (!isset($options['path'])) { throw new Exception("The parameter 'save_path' is required"); } ini_set('session.save_handler', 'redis'); ini_set('session.save_path', $options['path']); if (isset($options['name'])) { ini_set('session.name', $options['name']); } if (isset($options['lifetime'])) { ini_set('session.gc_maxlifetime', $options['lifetime']); } if (isset($options['cookie_lifetime'])) { ini_set('session.cookie_lifetime', $options['cookie_lifetime']); } parent::__construct($options); }
/** * {@inheritdoc} * * @param array $options * @throws Exception */ public function __construct($options = null) { if (!isset($options['db']) || !$options['db'] instanceof DbAdapter) { throw new Exception('Parameter "db" is required and it must be an instance of Phalcon\\Db\\AdapterInterface'); } $this->connection = $options['db']; unset($options['db']); if (!isset($options['table']) || empty($options['table']) || !is_string($options['table'])) { throw new Exception("Parameter 'table' is required and it must be a non empty string"); } $columns = ['session_id', 'data', 'created_at', 'modified_at']; foreach ($columns as $column) { $oColumn = "column_{$column}"; if (!isset($options[$oColumn]) || !is_string($options[$oColumn]) || empty($options[$oColumn])) { $options[$oColumn] = $column; } } parent::__construct($options); session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'gc']); }
/** * {@inheritdoc} * * @param array $options * @throws \Phalcon\Session\Exception */ public function __construct($options = null) { if (!isset($options['db'])) { throw new Exception("The parameter 'db' is required"); } if (!isset($options['db_table'])) { throw new Exception("The parameter 'db_table' is required"); } if (!isset($options['db_id_col'])) { throw new Exception("The parameter 'db_id_col' is required"); } if (!isset($options['db_data_col'])) { throw new Exception("The parameter 'db_data_col' is required"); } if (!isset($options['db_time_col'])) { throw new Exception("The parameter 'db_time_col' is required"); } parent::__construct($options); session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'gc']); }
/** * {@inheritdoc} * * @param array $options * @throws \Phalcon\Session\Exception */ public function __construct($options = null) { if (!isset($options['db'])) { throw new Exception("The parameter 'db' is required"); } if (!isset($options['table'])) { throw new Exception("The parameter 'table' is required"); } if (isset($options['name'])) { ini_set('session.name', $options['name']); } if (isset($options['lifetime'])) { ini_set('session.gc_maxlifetime', $options['lifetime']); } if (isset($options['cookie_lifetime'])) { ini_set('session.cookie_lifetime', $options['cookie_lifetime']); } parent::__construct($options); session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); }
/** * Phalcon\Session\Adapter\Redis constructor * * @param array $options */ public function __construct($options = null) { if (!isset($options['path'])) { throw new Exception("The parameter 'save_path' is required"); } ini_set('session.save_handler', 'redis'); if (is_array($options['path'])) { if (!isset($options['path'][0])) { $path = $options['path']; unset($options['path']); $options['path'] = [$path]; } $paths = []; foreach ($options['path'] as $val) { $path = 'tcp://'; $path .= $val['host']; unset($val['host']); $path .= ":" . $val['port']; unset($val['port']); if (!empty($val)) { $path .= "?" . http_build_query($val); } $paths[] = $path; } $options['path'] = implode(", ", $paths); } ini_set('session.save_path', $options['path']); if (isset($options['name'])) { ini_set('session.name', $options['name']); } if (isset($options['lifetime'])) { ini_set('session.gc_maxlifetime', $options['lifetime']); } if (isset($options['cookie_lifetime'])) { ini_set('session.cookie_lifetime', $options['cookie_lifetime']); } parent::__construct($options); }
/** * {@inheritdoc} * * @param array $options * * @throws \Phalcon\Session\Exception */ public function __construct($options = null) { if (!isset($options['db'])) { throw new Exception("The parameter 'db' is required"); } if (!isset($options['table'])) { throw new Exception("The parameter 'table' is required"); } if (!isset($options['column_session_id'])) { $options['column_session_id'] = 'session_id'; } if (!isset($options['column_data'])) { $options['column_data'] = 'data'; } if (!isset($options['column_created_at'])) { $options['column_created_at'] = 'created_at'; } if (!isset($options['column_modified_at'])) { $options['column_modified_at'] = 'modified_at'; } parent::__construct($options); session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); }
/** * Phalcon\Session\Adapter\Aerospike constructor * * @param array $options Constructor options * * @throws \Phalcon\Session\Exception * @throws \Phalcon\Cache\Exception */ public function __construct(array $options) { if (!isset($options['hosts']) || !is_array($options['hosts'])) { throw new Exception('No hosts given in options'); } if (isset($options['namespace'])) { $this->namespace = $options['namespace']; unset($options['namespace']); } if (isset($options['prefix'])) { $this->prefix = $options['prefix']; } if (isset($options['set']) && !empty($options['set'])) { $this->set = $options['set']; unset($options['set']); } if (isset($options['lifetime'])) { $this->lifetime = $options['lifetime']; } $persistent = false; if (isset($options['persistent'])) { $persistent = (bool) $options['persistent']; } $opts = []; if (isset($options['options']) && is_array($options['options'])) { $opts = $options['options']; } $this->db = new AerospikeDb(new FrontendData(['lifetime' => $this->lifetime]), ['hosts' => $options['hosts'], 'namespace' => $this->namespace, 'set' => $this->set, 'prefix' => $this->prefix, 'persistent' => $persistent, 'options' => $opts]); parent::__construct($options); session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'gc']); }
/** * Class constructor. * $session = new Phalcon\Session\Adapter\Libmemcached(array( * 'servers' => array( * array('host' => 'localhost', 'port' => 11211, 'weight' => 1), * ), * 'client' => array( * Memcached::OPT_HASH => Memcached::HASH_MD5, * Memcached::OPT_PREFIX_KEY => 'prefix.', * ), * 'lifetime' => 3600, * 'prefix' => 'my_' * )); * * @param null|array $options * @throws Phalcon\Session\Exception */ public function __construct($options = null) { if (empty($options)) { throw new Phalcon\Session\Exception("No configuration given"); } if (empty($options['servers']) || !is_array($options['servers'])) { throw new Phalcon\Session\Exception("No session servers given in options"); } foreach ($options['servers'] as $key => $server) { if (empty($server['host'])) { throw new Phalcon\Session\Exception("No session host given in options"); } $options['server'][$key] = array_merge(array('port' => self::DEFAULT_OPTION_PORT), $server); } if (!isset($options["lifetime"])) { $options["lifetime"] = self::DEFAULT_OPTION_LIFETIME; } if (!isset($options["prefix"])) { $options["prefix"] = self::DEFAULT_OPTION_PREFIX; } session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); parent::__construct($options); }
public function __construct($options = []) { parent::__construct($options); $this->options = $options; }
/** * Phalcon\Session\Adapter\Aerospike constructor * * @param array $options Constructor options * @throws Exception */ public function __construct(array $options) { if (!isset($options['hosts']) || !is_array($options['hosts'])) { throw new Exception('No hosts given in options'); } if (isset($options['namespace'])) { $this->namespace = $options['namespace']; } if (isset($options['prefix'])) { $this->prefix = $options['prefix']; } if (isset($options['lifetime'])) { $this->lifetime = $options['lifetime']; } $persistent = false; if (isset($options['persistent'])) { $persistent = (bool) $options['persistent']; } $opts = []; if (isset($options['options']) && is_array($options['options'])) { $opts = $options['options']; } $this->db = new AerospikeDb(['hosts' => $options['hosts']], $persistent, $opts); if (!$this->db->isConnected()) { throw new Exception(sprintf("Aerospike failed to connect [%s]: %s", $this->db->errorno(), $this->db->error())); } parent::__construct($options); session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'gc']); }
/** * @param array $options */ public function setOptions(array $options) { $options = array_merge($this->defaultOptions, $options); parent::setOptions($options); }