/** * Regenerates the global session id. * * @return void */ public function regenerate() { if (self::$config['driver'] === 'native') { session_regenerate_id(TRUE); $_SESSION['session_id'] = session_id(); } else { $_SESSION['session_id'] = self::$driver->regenerate(); } }
/** * validate a driver config value * * @param array array with configuration values * @access public * @return array validated and consolidated config */ public function _validate_config($config) { $validated = array(); foreach ($config as $name => $item) { // filter out any driver config if (!is_array($item)) { switch ($item) { case 'cookie_name': if (empty($item) or !is_string($item)) { $item = 'fuelrid'; } break; case 'database': // do we have a servers config if (empty($item) or !is_array($item)) { $item = 'default'; } break; default: break; } // global config, was validated in the driver $validated[$name] = $item; } } // validate all global settings as well return parent::_validate_config($validated); }
/** * validate a driver config value * * @param array array with configuration values * @access public * @return array validated and consolidated config */ public function _validate_config($config) { $validated = array(); foreach ($config as $name => $item) { if ($name == 'memcached' and is_array($item)) { foreach ($item as $name => $value) { switch ($name) { case 'cookie_name': if (empty($value) or !is_string($value)) { $value = 'fuelmid'; } break; case 'servers': // do we have a servers config if (empty($value) or !is_array($value)) { $value = array('default' => array('host' => '127.0.0.1', 'port' => '11211')); } // validate the servers foreach ($value as $key => $server) { // do we have a host? if (!isset($server['host']) or !is_string($server['host'])) { throw new \Fuel_Exception('Invalid Memcached server definition in the session configuration.'); } // do we have a port number? if (!isset($server['port']) or !is_numeric($server['port']) or $server['port'] < 1025 or $server['port'] > 65535) { throw new \Fuel_Exception('Invalid Memcached server definition in the session configuration.'); } // do we have a relative server weight? if (!isset($server['weight']) or !is_numeric($server['weight']) or $server['weight'] < 0) { // set a default $value[$key]['weight'] = 0; } } break; default: // unknown property continue; } $validated[$name] = $value; } } else { // skip all config array properties if (is_array($item)) { continue; } // global config, was validated in the driver $validated[$name] = $item; } } // validate all global settings as well return parent::_validate_config($validated); }
/** * validate a driver config value * * @param array array with configuration values * @access public * @return array validated and consolidated config */ public function _validate_config($config) { $validated = array(); foreach ($config as $name => $item) { // filter out any driver config if (!is_array($item)) { switch ($name) { case 'cookie_name': if (empty($item) or !is_string($item)) { $item = 'fueldid'; } break; case 'database': // do we have a database? if (empty($item) or !is_string($item)) { \Config::load('db', true); $item = \Config::get('db.active', false); } if ($item === false) { throw new \FuelException('You have specify a database to use database backed sessions.'); } break; case 'table': // and a table name? if (empty($item) or !is_string($item)) { throw new \FuelException('You have specify a database table name to use database backed sessions.'); } break; case 'gc_probability': // do we have a path? if (!is_numeric($item) or $item < 0 or $item > 100) { // default value: 5% $item = 5; } break; default: break; } // global config, was validated in the driver $validated[$name] = $item; } } // validate all global settings as well return parent::_validate_config($validated); }
/** * validate a driver config value * * @param array array with configuration values * @access public * @return array validated and consolidated config */ public function _validate_config($config) { $validated = array(); foreach ($config as $name => $item) { // filter out any driver config if (!is_array($item)) { switch ($name) { case 'cookie_name': if (empty($item) or !is_string($item)) { $item = 'fuelfid'; } break; case 'path': // do we have a path? if (empty($item) or !is_dir($item)) { throw new \FuelException('You have specify a valid path to store the session data files.'); } // and can we write to it? if (!is_writable($item)) { throw new \FuelException('The webserver doesn\'t have write access to the path to store the session data files.'); } // update the path, and add the trailing slash $item = realpath($item) . '/'; break; case 'gc_probability': // do we have a path? if (!is_numeric($item) or $item < 0 or $item > 100) { // default value: 5% $item = 5; } break; default: // no config item for this driver break; } // global config, was validated in the driver $validated[$name] = $item; } } // validate all global settings as well return parent::_validate_config($validated); }
/** * validate a driver config value * * @param array array with configuration values * @access public * @return array validated and consolidated config */ public function _validate_config($config) { $validated = array(); foreach ($config as $name => $item) { // filter out any driver config if (!is_array($item)) { switch ($name) { case 'cookie_name': if ( empty($item) OR ! is_string($item)) { $item = 'fuelcid'; } break; default: // no config item for this driver break; } // global config, was validated in the driver $validated[$name] = $item; } } // validate all global settings as well return parent::_validate_config($validated); }