I got one site to fix issues and noticed one very odd issue.
Below code is work well in DISABLE cache mode but not in ENABLE mode. If I enable cache then it only works on customer-account (customer/account) section but not other parts/pages of site.
Code snippet of path:
app/design/frontend/Company/developer/Magento_Theme/templates/html/header.phtml
$objectManagerlogin = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManagerlogin->get('Magento\Customer\Model\Session');
$baseurl = $objectManagerlogin->get('Magento\Store\Model\StoreManagerInterface')->getStore(0)->getBaseUrl();
if($customerSession->isLoggedIn()) {
echo "Logout";
}else {
echo "Login";
}
PS: I am aware that Object Manager should not be used and commands (static content, reindex, cacha clean, di compilation) ran completely.