I have to check whether a customer is logged in or not.
It only works for
My account page and for the rest of the pages, it gives a null result. It was working before.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->get('Magento\Customer\Model\Session'); $customerSession->isLoggedIn();
This code only works for My Account page, and for all other pages, it gives the empty result.
I tried this in my
header.phtml as I need loggedIn condition in my
header.phtml but it doesn't work.
$om = \Magento\Framework\App\ObjectManager::getInstance(); $context = $om->get('Magento\Framework\App\Http\Context'); $isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
Still, this doesn't work in my
What the issue, how to resolve it.