[英]Unset Twig Session Variables
How can we destroy the session variable in twig? 我们如何在树枝中销毁会话变量? I can get session variables by app.session.get('$name'). 我可以通过app.session.get('$ name')获取会话变量。 And I want to destroy it afterwards for some purposes. 我想在某些目的之后销毁它。
Thanx! 感谢名单!
Flash Messages are the right way to do this. Flash消息是执行此操作的正确方法。
Symfony2 Cookbook example: Symfony2 Cookbook示例:
{% if app.session.hasFlash('notice') %}
<div class="flash-notice">
{{ app.session.flash('notice') }}
</div>
{% endif %}
For more information check the Symfony documentation flash messages . 有关更多信息,请查看Symfony文档Flash消息 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.