本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Session::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::__construct方法的具体用法?PHP Session::__construct怎么用?PHP Session::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Session\Session
的用法示例。
在下文中一共展示了Session::__construct方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* {@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));
}
}
示例2: __construct
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);
}
示例3: __construct
/**
* 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);
}
示例4: __construct
/**
* 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();
}
示例5: __construct
/**
* @param SessionStorageInterface $storage
*/
public function __construct(SessionStorageInterface $storage)
{
parent::__construct($storage);
}
示例6: __construct
public function __construct(ConfigBuilderInterface $config)
{
$this->config = $config;
parent::__construct();
}
示例7: __construct
public function __construct()
{
$handle = new NativeFileSessionHandler(cache_path('session/'));
$storage = new NativeSessionStorage(['use_cookies' => 0], $handle);
parent::__construct($storage);
}
示例8: __construct
public function __construct(SessionStorageInterface $storage, AttributeBagInterface $attributes, FlashBagInterface $flashes)
{
parent::__construct($storage, $attributes, $flashes);
}
示例9: __construct
/**
* 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);
}
示例10: __construct
/**
* {@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);
}