Can anyone tell me how to add 'sign out' option after the user is logged in on header links in Magento 2.3.X https://prnt.sc/oqe2ue
Asked
Active
Viewed 1,125 times
1 Answers
0
If you want to add custom logout link in header than,You can add below code in test.phtml and than call this phtml in layout
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); ?>
<?php $customerSession = $objectManager->get('Magento\Customer\Model\Session');?>
<?php if($customerSession->isLoggedIn()):?>
<li><a href="<?php echo $this->getUrl('customer/account/logout') ?>">Logout</a></li>
<?php endif; ?>
Add this phtml to lyout default.xml in theme
<referenceContainer name="header.panel.wrapper" >
<block class="Magento\Framework\View\Element\Template" name="nameOfBlock" as="header" template="Magento_Theme::test.phtml"/>
</referenceContainer>
moni patel
- 47
- 11
\Magento\Framework\App\Http\Context $httpContextthis dependency we are getting customer login or not – Rakesh Donga Aug 09 '19 at 09:30