Usually, we can check whether a customer is logged in via the Customer Session (Magento\Customer\Model\Session) class. Sometimes when a full-page cache is enabled, the generic class will not work as per our expectation. So in that case we can use HttpContext (Magento\Framework\App\Http\Context) class to check whether a customer is logged in or not. HttpContext class […]
Check if customer logged using HttpContext in Magento 2
Easy way to check whether customer logged in or not via customer Js component in phtml file. <div data-bind="scope: 'customer'"> <!-- ko if: customer().fullname --> Logged In customer <!-- /ko --> <!-- ko ifnot: customer().fullname --> Notlogged In customer <!-- /ko --> </div> <script type="text/x-magento-init"> { "*": { "Magento_Ui/js/core/app": { "components": { "customer": { "component": […]

