Magento 2 - Check If Customer Login Or Not

Magento 2 - Check If Customer Login Or Not

protected $customerSession;

public function __construct(
    \Magento\Customer\Model\SessionFactory $customerSession
) {
    $this->customerSession = $customerSession;
}

public function isLoggedIn()
{
    return $this->customerSession->create()->isLoggedIn();
}
use isLoggedIn() to check customer login or not

Comments