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

Skip to content

Commit eb8d8eb

Browse files
author
Tom Avery
committed
{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 d15bb73 commit eb8d8eb

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
@@ -210,13 +210,15 @@ public function regenerate($destroy = false, $lifetime = null)
210210
$ret = session_regenerate_id($destroy);
211211

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

222224
return $ret;

0 commit comments

Comments
 (0)