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.

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

1 Answer 1


somewhere file .phtml

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

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

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

Your Answer

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

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