After a customer is logged in, when I check if the customer is logged in or not, it returns true only on the customer account page and returns false on every other page like home page, product page, etc. This is the code which I am using to check
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
<?php if($customerSession->isLoggedIn()) {
echo "YEs logged in";
}?>