fabpot/Silex — Issue #274: Session not started in before event
Author: ranza
Created: 2012-03-08 16:21:13+00:00
State: open

It looks like an issue simular to https://github.com/fabpot/Silex/issues/154 is back. Im adding a before event in a ControllerProvider like so in the code below. Im forced to start the session as it wont be available if I dont. Isnt it supposed to load on dispatching?

```PHP
$app['dispatcher']->addListener(SilexEvents::BEFORE, function (GetResponseEvent $event) use ($app) {
$request = $event->getRequest();
if ($request->getRequestUri() === $app['url_generator']->generate('login')) {
return;
}

// Force session to start
$app['session']->start();

if (!$app['session']->get('isAuthenticated')) {
$ret = $app->redirect($app['url_generator']->generate('login'));
} else {
$ret = null;
}

if ($ret instanceof Response) {
$event->setResponse($ret);
}
}, 0);
```