diff --git a/Controller/Controller.php b/Controller/Controller.php index b320347..a9e1ba2 100644 --- a/Controller/Controller.php +++ b/Controller/Controller.php @@ -45,9 +45,9 @@ public function __construct(private mixed $serializer, private ExposedRoutesExtr public function indexAction(Request $request, $_format): Response { - $session = $request->hasSession() ? $request->getSession() : null; - - if ($request->hasPreviousSession() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if (!$request->attributes->getBoolean('_stateless') && $request->hasSession() + && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag + ) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); }