How to check If Customer is Logged In or Not Magento 2?
-
Nidhi Arora
- 8 years

Method 1. To check the customer is logged or not on any page of the website:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->get('Magento\Customer\Model\Session'); if($customerSession->isLoggedIn()) { // customer login action }
Method 2. To check if customer is logged from controller:
$this->_objectManager->get('Magento\Customer\Model\Session'); if($customerSession->isLoggedIn()) { // customer login action }
If you still have any query regarding this “How to” or would like to add some suggestions to this solution, let us know your feedback or query at sales@envisionecommerce.com, and don’t forget to share this “How to” blog with your fellow Magento 2 users!
Download Blog