Closed AlexandreGagner closed 4 months ago
Slim processes middleware in a Last In, First Out (LIFO) order. This means the last middleware added is the first one to be executed. If you add multiple middleware components, they will be executed in the reverse order of their addition. In your case, SessionStartMiddleware will be executed at the end, but some other middleware may need a started session.
Try to move the $app->add(SessionStartMiddleware::class);
call down to execute it earlier.
Example:
return function (App $app) {
$app->add(SentryMiddleware::class);
$app->add(AuthMiddleware::class);
$app->addBodyParsingMiddleware();
$app->add(TwigMiddleware::class);
$app->add(SessionStartMiddleware::class); // <--- new position
$app->addRoutingMiddleware();
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware());
};
Thanks it's working ! Completely forgot about LIFO in slim 4.
Regards
Hello, I updated my slim 4 base with the v6 ans followed all v6 doc/integration.
I feel i missed something because the session are not starting when i register the SessionStartMiddleware :
I have to start it the container definition (i believe DI container should not start a session automatically as mentioned in v6 doc). I'm missing somethings ?
Thanks 😅