Share icon

In the new era the drupal8 twig is introduce, so old basic php drupal hook is not useful in theme templates. Now twig is power under the template and if you want to know the user is logged in or Not you can use the following method in your template like node.html.twig or html.html.twig or page.html.twig etc 

{% if logged_in %}
 !!!! do you stuff !!!
{% else %}
 !!!! do you stuff !!!
{% endif %}

Its Just a simple thing helps to add script, or your static html or dynamic coding 

Happy Coding, Have Fun

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.