Skip to content

Commit 99adcf1

Browse files
Tom Averyfabpot
Tom Avery
authored andcommitted
{HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage
Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)". This patch applies the first fix only if the session store is "files" {HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)". This patch applies the first fix only if the session store is "files"
1 parent bd4488b commit 99adcf1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ public function regenerate($destroy = false, $lifetime = null)
208208
$ret = session_regenerate_id($destroy);
209209

210210
// workaround for https://bugs.php.net/bug.php?id=61470 as suggested by David Grudl
211-
session_write_close();
212-
if (isset($_SESSION)) {
213-
$backup = $_SESSION;
214-
session_start();
215-
$_SESSION = $backup;
216-
} else {
217-
session_start();
211+
if($this->getSaveHandler()->getSaveHandlerName() === 'files') {
212+
session_write_close();
213+
if (isset($_SESSION)) {
214+
$backup = $_SESSION;
215+
session_start();
216+
$_SESSION = $backup;
217+
} else {
218+
session_start();
219+
}
218220
}
219221

220222
return $ret;

0 commit comments

Comments
 (0)