Customer Logout programmatically in Magento 2.

Magento 2, You can log out customer programmatically by getting current customer session using the Model file, Magento\Customer\Model\Session

You need to call logout() function from above class dependency.
Call below dependency in __construct function,

Call customerLogout() function from above file to programmatically log out a customer from the current session.

One Reply to “Customer Logout programmatically in Magento 2.”

Leave a Reply

Your email address will not be published. Required fields are marked *