/** * {@inheritDoc} * * modified to set session cookie name dynamically so admin and storefront * cookies are separated. It should be closer to native session storage, * but it is not worth it to extend/modify another class yet. */ public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) { parent::__construct($storage, $attributes, $flashes); if (null !== ($context = Runtime::getContext())) { $this->storage->setOptions(array('name' => 'zm-' . $context)); } }
public function __construct(array $config = array()) { $handler = isset($config['handler']) ? $config['handler'] : 'native'; $config = isset($config['config']) ? $config['config'] : array(); try { switch ($handler) { case "memcached": $storage = $this->configureMemcachedHandler($config); break; default: $storage = new NativeSessionHandler(); break; } } catch (\Exception $e) { $storage = new NativeSessionHandler(); } $storage = new MockArraySessionStorage(); /* $storage = new NativeSessionStorage(array( "name"=> "hmmmm", "id"=> "hmmmm", "path"=> "/" ), $storage ); */ parent::__construct($storage); }
/** * Constructor. * * @param SessionStorageInterface $storage A SessionStorageInterface instance. * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default * AttributeBag) * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) */ public function __construct(SessionStorageInterface $storage = NULL, AttributeBagInterface $attributes = NULL, FlashBagInterface $flashes = NULL) { parent::__construct($storage, $attributes, $flashes); $errorsBag = new ErrorBag(); $this->errorBagName = $errorsBag->getName(); $this->registerBag($errorsBag); }
/** * Constructor. * * @param SessionStorageInterface $storage A SessionStorageInterface instance. * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) * @param FlashBagInterface $autoExpireFlashBag A FlashBagInterface instance (defaults null for default FlashBag) */ public function __construct(Application $app, SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, FlashBagInterface $autoExpireFlashBag = null, $sTokenNamespace = 'csrf') { $this->app = $app; parent::__construct($storage, $attributes, $flashes); if (null === $autoExpireFlashBag) { $autoExpireFlashBag = new AutoExpireFlashBag(); } $this->autoExpireFlashName = $autoExpireFlashBag->getName(); $this->registerBag($autoExpireFlashBag); $this->start(); $this->sTokenNamespace = $sTokenNamespace; $this->setToken(); }
/** * @param SessionStorageInterface $storage */ public function __construct(SessionStorageInterface $storage) { parent::__construct($storage); }
public function __construct(ConfigBuilderInterface $config) { $this->config = $config; parent::__construct(); }
public function __construct() { $handle = new NativeFileSessionHandler(cache_path('session/')); $storage = new NativeSessionStorage(['use_cookies' => 0], $handle); parent::__construct($storage); }
public function __construct(SessionStorageInterface $storage, AttributeBagInterface $attributes, FlashBagInterface $flashes) { parent::__construct($storage, $attributes, $flashes); }
/** * Session constructor. * @param array|String $options * *********************************************************************************** * #------------- [options] -------------# * List of options for $options array with their defaults. * * @see http://php.net/session.configuration for options * but we omit 'session.' from the beginning of the keys for convenience. * * ("auto_start", is not supported as it tells PHP to start a session before * PHP starts to execute user-land code. Setting during runtime has no effect). * * cache_limiter, "" (use "0" to prevent headers from being sent entirely). * cookie_domain, "" * cookie_httponly, "" * cookie_lifetime, "0" * cookie_path, "/" * cookie_secure, "" * entropy_file, "" * entropy_length, "0" * gc_divisor, "100" * gc_maxlifetime, "1440" * gc_probability, "1" * hash_bits_per_character, "4" * hash_function, "0" * name, "PHPSESSID" * referer_check, "" * serialize_handler, "php" * use_cookies, "1" * use_only_cookies, "1" * use_trans_sid, "0" * upload_progress.enabled, "1" * upload_progress.cleanup, "1" * upload_progress.prefix, "upload_progress_" * upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS" * upload_progress.freq, "1%" * upload_progress.min-freq, "1" * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" * * * #------------- [handler] -------------# * prefix, "sid_" * expiretime, 86400 * *********************************************************************************** * * @param boolean $createNew Create new session id, destroy old session from cookie and storage. * @param null|String $driver * @param null|string $driverConfig */ public function __construct($options, $createNew = false, $driver = null, $driverConfig = null) { is_string($options) && ($options = config($options)); $options = $options ?: config(env("SESSION_DEFAULT_OPTIONS")); if (!$options || !$options['handler'] || !$options['options']) { throw new \RuntimeException("Invalid options: " . var_export($options, true)); } $driver = $driver ?: env("SESSION_DRIVER", 'file'); $driverConfig = $driverConfig ?: env("SESSION_DRIVER_CONFIG"); $optionsHandler = $options['handler']; switch ($driver = strtolower($driver)) { case 'redis': case 'predis': case 'memcache': case 'memcached': case 'mongodb': case 'mongo': case 'pdo': case 'file': $handler = call_user_func_array([$this, "{$driver}SessionHandler"], [$driverConfig, $optionsHandler]); break; default: throw new \RuntimeException("The session driver not support."); break; } $optionsStorage = $options['options']; $storage = new NativeSessionStorage($optionsStorage, $handler); $attributes = new AttributeBag("_ips_attributes"); if ($createNew) { $session_name = isset($options['options']['name']) ? $options['options']['name'] : "PHPSESSID"; if (isset($_COOKIE[$session_name])) { $old_session_id = $_COOKIE[$session_name]; $_COOKIE[$session_name] = null; @$storage->getSaveHandler()->destroy($old_session_id); } } parent::__construct($storage, $attributes); }
/** * {@inheritDoc} */ public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, ConversationBag $conversations = null) { parent::__construct($storage, $attributes, $flashes); $this->conversationName = $conversations->getName(); $this->registerBag($conversations); }