Now I implement the code below
use MagentoFrameworkAppHelperAbstractHelper;
use MagentoCustomerModelSession;
use MagentoFrameworkAppHttpContext as AuthContext;
class Customer extends AbstractHelper
{
/**
* @var MagentoFrameworkAppHttpContext
*/
private $httpContext;
private $objectmanager;
private $authContext;
public function __construct(
MagentoFrameworkAppHelperContext $context,
MagentoFrameworkAppHttpContext $httpContext,
MagentoFrameworkObjectManagerInterface $objectmanager,
Session $session,
AuthContext $authContext
) {
$this->objectmanager = $objectmanager;
$this->httpContext = $httpContext;
$this->customerSession = $session;
$this->authContext = $authContext;
parent::__construct($context);
}
public function isLoggedIn()
{
$isLoggedIn = $this->authContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
return $isLoggedIn;
}
But when I refresh my page it still say that it’s login eventhough I already logged out. Below is the code of my template
< ?php
$customerHelper = $this->helper('VendorModuleHelpersCustomer');
?>