I am trying to get loggedIn customer ID, I logged in and it is also showing in Online customer grid in the backend also can see on frontend. But if I check by
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
echo "login";
}
It gives out as not logged in. (using DI way also result is same)
Also
$ID = var_dump($this->_customerSession->isLoggedIn());
echo $ID;
It gives output as:
bool(false)
How can I get Logged In customer ID from session ?