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.

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

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. – Saravanan DS Jan 18 at 5:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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