{#
The check is needed to prevent starting the session when looking for "flash messages":
https://symfony.com/doc/current/session.html#avoid-starting-sessions-for-anonymous-users
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 %}
<div class="messages">
{% for type, messages in app.flashes %}
{% for message in messages %}
<div class="alert alert-dismissible alert-{{ type }} fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="{{ 'action.close'|trans }}">
<span aria-hidden="true">×</span>
</button>
{{ message|trans }}
</div>
{% endfor %}
{% endfor %}
</div>
{% endif %}#}
{% for type, messages in app.session.flashBag.all %}
{% for message in messages %}
<div class="alert alert-{{ type }} alert-dismissible fade show mb-2" role="alert">
<i class="mdi mdi-alert-circle-outline me-2"></i>
{{ message|trans({}, 'FOSUserBundle') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endfor %}