Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 added 6 characters in body
source | link

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

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.

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.

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.

2 added 12 characters in body
source | link

I got one site to fix issues and noticed one very odd issue.

Below code is work well in DISABLEDISABLE cache mode but not in ENABLEENABLE 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.

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.

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.

1
source | link

Customer Session works differenlty with cache

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.