Sorry if this question was asked before I could not find it. I could not find the answer I was looking for.
I have an outdated application that I am rebuilding using Symfony2, unfortunately, I need to work in parallel for a while, until I can finish rebuilding the entire system. I'm in the part where I need to have symfony in order to be able to access legacy session data so that it can function.
I found this on the Symfony website: http://symfony.com/doc/current/cookbook/session/php_bridge.html
http://symfony.com/doc/current/components/http_foundation/session_php_bridge.html
But I don’t understand what the configuration was supposed to happen, and where Im was supposed to trigger the start of the session, and also how to access the session data from my new application.
Would I place an example in symfony in every controller that I create?
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
// legacy application configures session
ini_set('session.save_handler', 'files');
ini_set('session.save_path', '/tmp');
session_start();
// Get Symfony to interface with this existing session
$session = new Session(new PhpBridgeSessionStorage());
// symfony will now interface with the existing PHP session
$session->start();
There seems to be a way to centralize it.
UPDATE
The manual provides an example, but it does not say whether it should reside in a controller, service, entity, or configuration somewhere.
I tried using the sample code in the controller, and when I do print_r in session $, I do not see any stale session data.
**
Thanks in advance.
source
share