I have two applications. One of the obsolete ones is written in the Zend Framework, and the new one in Symfony 3.1 should share the session with the old one.
The old application uses its own file storage, so when I go to app_dev.php and I write session_start(); var_dump($_SESSION); session_start(); var_dump($_SESSION); , I see "__ZF" in the session, and I need to access it in a symfony3 application.
Obviously, the code above was only for checking if the session is shared in the domain.
In the symfony3 application, I tried to describe the KernelEvents::REQUEST event and there I wanted to get a raw session from the request and create a package with the parameters that come from Zend2.
class SessionSubscriber implements EventSubscriberInterface { public function onKernelRequest(GetResponseEvent $event) { if ($event->isMasterRequest() && true == $event->getRequest()->hasSession()) { var_dump($event->getRequest()); $event->getRequest()->getSession()->registerBag(new ZendSessionBag()); var_dump($event->getRequest()->getSession()->getBag('zf')); exit; return; } } public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => (array('onKernelRequest', 127)) ); } }
But I do not have access to raw session data from $event->getRequest();
This is what my bag looks like. As far as I understand, I should have access to the raw session data in the initialize () method
class ZendSessionBag implements SessionBagInterface { private $storageKey; private $sessionData; public function __construct($storageKey = '__ZF') { $this->storageKey = $storageKey; } public function getName() { return 'zf'; } public function initialize(array &$array) { var_dump($array);
So when I get the session and then get the bag named "zf", I will have access to the data.
This is also my configuration regarding sessions:
session: storage_id: session.storage.php_bridge handler_id: session.handler.native_file save_path: "/var/lib/php5/sessions"
Any help would be greatly appreciated.
php symfony session zend-framework2
Robert
source share