I\'m in the process of setting up the ability to migrate from a Legacy codebase to a Symfony one, and I\'m trying to share legacy session variables between the two applicati
Is there any complicated life-cycle for your session variables? Or they are mainly read-only once you're logged in into your application?
If the latter applies, you might be able to add that "hack" into an event subscriber. This subscriber would listen for the Interactive Login Event, and it could look something like:
class PortSessionHandler implements EventSubscriberInterface
{
private $session;
public function __construct(SessionInterface $session) {
$this->session = $session;
}
public static function getSubscribedEvents()
{
return [
SecurityEvents::INTERACTIVE_LOGIN => [
['portLegacySession']
]
];
}
public function portLegacySession(InteractiveLoginEvent $event)
{
//here you could populate SF2 session with legacy session
$this->session->set('user_id', $_SESSION['user_id']);
...
}
}
Hope this helps