{# The request method check is needed to prevent starting the session when looking for "flash messages": https://symfony.com/doc/current/session/avoid_session_start.html TIP: With FOSHttpCache you can also adapt this to make it cache safe: https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html #} {% if app.request.hasPreviousSession is defined and app.request.hasPreviousSession %} {% for type, messages in app.flashes %} {% for message in messages %}