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 straightforward way to check if a user is not logged in.
I'm aware that comparing app.user.username
with anon
works, but that just doesn't feel right to me.
You can check if app.user is set.
{% if app.user %} # user is logged in {% else %} # user is not logged in {% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With