[HttpFoundation] Removed erroneous reliance on session.auto_start
This commit is contained in:
parent
dcac5d7fd6
commit
19eeac88ca
@ -61,7 +61,9 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||||||
* @see http://php.net/session.configuration for options
|
* @see http://php.net/session.configuration for options
|
||||||
* but we omit 'session.' from the beginning of the keys for convenience.
|
* but we omit 'session.' from the beginning of the keys for convenience.
|
||||||
*
|
*
|
||||||
* auto_start, "0"
|
* ("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, "nocache" (use "0" to prevent headers from being sent entirely).
|
* cache_limiter, "nocache" (use "0" to prevent headers from being sent entirely).
|
||||||
* cookie_domain, ""
|
* cookie_domain, ""
|
||||||
* cookie_httponly, ""
|
* cookie_httponly, ""
|
||||||
@ -95,8 +97,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
||||||
{
|
{
|
||||||
// sensible defaults
|
|
||||||
ini_set('session.auto_start', 0); // by default we prefer to explicitly start the session using the class.
|
|
||||||
ini_set('session.cache_limiter', ''); // disable by default because it's managed by HeaderBag (if used)
|
ini_set('session.cache_limiter', ''); // disable by default because it's managed by HeaderBag (if used)
|
||||||
ini_set('session.use_cookies', 1);
|
ini_set('session.use_cookies', 1);
|
||||||
|
|
||||||
@ -256,10 +256,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||||||
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
|
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ini_get('session.auto_start') && !$this->started) {
|
if ($this->saveHandler->isActive() && !$this->started) {
|
||||||
$this->start();
|
|
||||||
} elseif ($this->saveHandler->isActive() && !$this->started) {
|
|
||||||
$this->loadSession();
|
$this->loadSession();
|
||||||
|
} elseif (!$this->started) {
|
||||||
|
$this->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->bags[$name];
|
return $this->bags[$name];
|
||||||
@ -302,7 +302,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||||||
public function setOptions(array $options)
|
public function setOptions(array $options)
|
||||||
{
|
{
|
||||||
$validOptions = array_flip(array(
|
$validOptions = array_flip(array(
|
||||||
'auto_start', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
||||||
'cookie_lifetime', 'cookie_path', 'cookie_secure',
|
'cookie_lifetime', 'cookie_path', 'cookie_secure',
|
||||||
'entropy_file', 'entropy_length', 'gc_divisor',
|
'entropy_file', 'entropy_length', 'gc_divisor',
|
||||||
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
|
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
|
||||||
|
Reference in New Issue
Block a user