Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5be2f4c

Browse files
committed
Allow to set options & handler only if session is not active
1 parent 01e4d2d commit 5be2f4c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ public function __construct(array $options = array(), \SessionHandlerInterface $
9090
{
9191
$this->setMetadataBag($metaBag);
9292

93-
if (\PHP_SESSION_ACTIVE !== session_status()) {
93+
if (\PHP_SESSION_ACTIVE === session_status()) {
94+
if (!empty($options) || null !== $handler) {
95+
throw new \LogicException('Cannot change options or handler of an active session');
96+
}
97+
} else {
9498
$options += array(
9599
// disable by default because it's managed by HeaderBag (if used)
96100
'cache_limiter' => '',
97101
'use_cookies' => 1,
98102
);
99-
103+
100104
session_register_shutdown();
101105

102106
$this->setOptions($options);

0 commit comments

Comments
 (0)