How can I remove certain elements in the layout, but only when the customer is not logged in? In Magento 1, there was a logged in handle, but is there an equivalent in Magento 2?


2 Answers 2


I think you are looking for the alternatives of customer_logged_in and customer_logged_out layout handles which are available in M1. Unfortunately the answer is NO. We don't have such layout handles available in M2.

But you have two events for this. They are customer_login and customer_logout. You need to use these events to achieve the desired result.

If you need this behavior via layout updates, then the only option which comes to my mind is the conditional blocks. However this only allows system configuration settings and hence cannot rely on this.

So in short, the desired behavior is not possible via layout updates and hence you need to look for other work around such as this


More details are in this link


There are two different handle for magento 2 also,

customer_account_index.xml Used when the customer is Login,

customer_account_login.xml used when the customer is guest(not login)

  • Yes, but is there also a (for example), default.xml type layout file, specifically for logged in / not logged in users? Commented Apr 3, 2018 at 9:42
  • This is not right answer
    – Sourav
    Commented Apr 3, 2018 at 10:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.