Magento 2: How to use the Layout Handle customer_logged_in?
Answer to your question is definitely no, there is no customer_logged_in
handle anymore, I've digged into the code and could not find any layout handle that could do the trick.
On top of that under \dev\tests\static\testsuite\Magento\Test\Legacy\LayoutTest.php
you can find the following code:
/**
* List of obsolete nodes
*
* @var array
*/
protected $_obsoleteNodes = [
'PRODUCT_TYPE_simple',
'PRODUCT_TYPE_configurable',
'PRODUCT_TYPE_grouped',
'PRODUCT_TYPE_bundle',
'PRODUCT_TYPE_virtual',
'PRODUCT_TYPE_downloadable',
'PRODUCT_TYPE_giftcard',
'catalog_category_default',
'catalog_category_layered',
'catalog_category_layered_nochildren',
'customer_logged_in',
'customer_logged_out',
'customer_logged_in_psc_handle',
'customer_logged_out_psc_handle',
'cms_page',
'sku_failed_products_handle',
'catalog_product_send',
'reference',
];
Which to me, clearly tells us that the customer_logged_in
layout handle is obsolete now.
See Fabian's answer for explanations about how it is done now in Magento 2.
As others have pointed out, these handles are now gone. If you look at the Magento_Customer module, you'll see that blocks like the registration link are always added but not rendered if the customer is logged in. It looks like this is now the preferred way to show elements conditionally depending on login state.
But this is not a solution for removing blocks based on their name, that were defined somewhere else. You could recreate the feature with an observer for layout_load_before
that calls $layout->addHandle('customer_logged_in')
if the customer is logged in.
If anyone is still struggling with this I wrote a quick module that adds the customer_logged_in and customer_logged_out layout handles for you to use just like in Magento 1
http://frankclark.xyz/modules/magento-2-get-customer_logged_in-and-customer_logged_out-layout-handles
Enjoy !