How to make my blocks switch to another block when session was set? I have 2 header block, default 1 is the login form and the other block was for logout button. I want to make this two blocks switching after triggering the login button
You can do this in code:

if (\Drupal::currentUser()-&gt;isAnonymous()) {}


Or in block layout by configuring the visibility of roles:

When the user has the following roles


Anonymous user
Authenticated user
Administrator


The first block for anonymous users and the second block for authenticated users.