Skip to content

Instantly share code, notes, and snippets.

@tcz
Created March 25, 2014 06:17
Show Gist options
  • Save tcz/9756112 to your computer and use it in GitHub Desktop.
Save tcz/9756112 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
/**
* Session sotrage that avoids using _sf2_attributes subkey
* in the $_SESSION superglobal but instead it uses
* the root variable.
*/
class LegacySessionStorage extends NativeSessionStorage
{
const SYMFONY_SESSION_SUBKEY = '_sf2_attributes';
/**
* @inheritdoc
*/
protected function loadSession(array &$session = null)
{
if (null === $session) {
$session = &$_SESSION;
}
parent::loadSession($session);
foreach ($this->bags as $bag) {
$key = $bag->getStorageKey();
if (self::SYMFONY_SESSION_SUBKEY === $key)
{
$bag->initialize($session);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment