0

In Magento 2.2.5, I am checking the customer is logged in or not in order to display the login link in case if he is not logged in. If he is logged In means I need to display the My Account link.

When I am trying to login, it is logging in correctly and when navigating to other page, In header menu it is showing the Login even after login.

Any solution for this.

Note: I have disabled page cache in backend.

2
  • Are you using customized theme? You should use KnockoutJS and Html template to display login state of the customer. That will work with FPC. Jan 11, 2019 at 7:31
  • I have customized luma theme. Can you share the code. Jan 11, 2019 at 8:11

1 Answer 1

0

somewhere file .phtml

$customerSession = $objectManager->get('Magento\Customer\Model\Session');

if($customerSession->isLoggedIn()) { //do something here... }

1
  • I used this code only. But it is still showing the login link only even after loggedIn. Jan 18, 2019 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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