customerSession = $session;
$this->authContext = $authContext;
parent::__construct($context);
}
public function execute()
{
// by using Session model
if($customerSession->isLoggedIn()) {
// customer login code
}else{
// customer not login
}
// using HTTP context
$isLoggedIn = $this->authContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
if ($isLoggedIn) {
// echo "Please log in to view this content.";
}
}
}