Skip to content

Commit

Permalink
{HttpFoundation] [Session] fixed session compatibility with memcached…
Browse files Browse the repository at this point in the history
…/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"
  • Loading branch information
Tom Avery authored and fabpot committed Aug 17, 2013
1 parent bd4488b commit 99adcf1
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -208,13 +208,15 @@ public function regenerate($destroy = false, $lifetime = null)
$ret = session_regenerate_id($destroy);

// workaround for https://bugs.php.net/bug.php?id=61470 as suggested by David Grudl
session_write_close();
if (isset($_SESSION)) {
$backup = $_SESSION;
session_start();
$_SESSION = $backup;
} else {
session_start();
if($this->getSaveHandler()->getSaveHandlerName() === 'files') {
session_write_close();
if (isset($_SESSION)) {
$backup = $_SESSION;
session_start();
$_SESSION = $backup;
} else {
session_start();
}
}

return $ret;
Expand Down

0 comments on commit 99adcf1

Please sign in to comment.