@@ -188,8 +188,8 @@ For more information, see the :doc:`Routing chapter </routing>`.
188188
189189.. caution ::
190190
191- The ``redirect() `` method does not check its destination in any way. If you
192- redirect to some URL provided by the end-users, your application may be open
191+ The ``redirect() `` method does not check its destination in any way. If you
192+ redirect to some URL provided by the end-users, your application may be open
193193 to the `unvalidated redirects security vulnerability `_.
194194
195195
@@ -425,21 +425,43 @@ read any flash messages from the session:
425425 .. code-block :: html+twig
426426
427427 {# app/Resources/views/base.html.twig #}
428- {% for flash_message in app.session.flashBag.get('notice') %}
428+
429+ {# you can read and display just one flash message type... #}
430+ {% for flash_message in app.session.flash('notice') %}
429431 <div class="flash-notice">
430432 {{ flash_message }}
431433 </div>
432434 {% endfor %}
433435
436+ {# ...or you can read and display every flash message available #}
437+ {% for type, flash_messages in app.session.flashes %}
438+ {% for flash_message in flash_messages %}
439+ <div class="flash-{{ type }}">
440+ {{ flash_message }}
441+ </div>
442+ {% endif %}
443+ {% endfor %}
444+
434445 .. code-block :: html+php
435446
436447 <!-- app/Resources/views/base.html.php -->
448+
449+ // you can read and display just one flash message type...
437450 <?php foreach ($view['session']->getFlash('notice') as $message): ?>
438451 <div class="flash-notice">
439- <?php echo "<div class='flash-error'> $message</div>" ?>
452+ <?php echo $message ?>
440453 </div>
441454 <?php endforeach ?>
442455
456+ // ...or you can read and display every flash message available
457+ <?php foreach ($view['session']->getFlashes() as $type => $flash_messages): ?>
458+ <?php foreach ($flash_messages as $flash_message): ?>
459+ <div class="flash-<?php echo $type ?>">
460+ <?php echo $message ?>
461+ </div>
462+ <?php endforeach ?>
463+ <?php endforeach ?>
464+
443465.. note ::
444466
445467 It's common to use ``notice ``, ``warning `` and ``error `` as the keys of the
0 commit comments