Flash messages are the right way to do this.
Symfony2 cookbook example:
{% if app.session.hasFlash('notice') %} <div class="flash-notice"> {{ app.session.flash('notice') }} </div> {% endif %}
For more information, check out the Symfony Flash message documentation.
source share