Symfony 2: How do I check if a user is not logged in inside a template?

后端 未结 2 1129
谎友^
谎友^ 2020-12-04 07:35

In Symfony 2 templates (using Twig), how can I effectively check whether a user is not logged in?

I don\'t want to use ROLE checks. I want a straightfor

2条回答
  •  囚心锁ツ
    2020-12-04 08:17

    You can check if app.user is set.

     {% if app.user %}
        # user is logged in
     {% else %}
        # user is not logged in
     {% endif %}
    

提交回复
热议问题