free
web stats

Fill the form & Get Installation Support

Connect With Us





captcha

Connect With Us





captcha

How to check customer is authenticated(login) or not in Magento 2?

Customer Authentication in Magento 2 is required when we have to check the customer is a guest user or a login user.

There are many occasions when we have to check the customer is login or not, and based on the login customer, only we have to show a specific page; otherwise, redirect it to the login page.

To verify whether it’s a login customer or not,
use \Magento\Customer\Model\Session Class and add the Customer Session class to the
 __construct() method of your Controller.

Using this approach, we can check the customer is a login customer or not.

Was this article helpful?
YesNo
Fill the below form if you have any Magento programming need.




captcha