Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Redirect Customer to Previous Page After Successful Login - Magento

In Magento by default, customers are redirected to ‘Customer Account Dashboard’ page after login. This feature can be easily changed from Magento configuration settings.

Configuration Settings


  1. Login to admin panel
  2. Go to System -> Configuration -> CUSTOMERS -> Customer Configuration -> Login Options
  3. Set: Redirect Customers to Account Dashboard after Loggin in = No
Magento customer configuration

This setting will redirect customers to the page from where they have come to login page. This setting is applicable for all pages of your Magento website.

You might have another condition of having this feature only on some specific pages.
For example, you might want this feature only on product view page. Or, you might have a category that is visible to logged in customers only. In this case, you can simply use the following code:

Redirect customer to login page for specific pages.

if(!Mage::helper('customer')->isLoggedIn()) {
 Mage::getSingleton('customer/session')
            ->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); 
 $this->_redirect('customer/account/login');
}

Customers will be redirected to previous page after successful login.

Hope this will help. Thanks.

Please support us, Like us on Facebook.

  1. Thanks for sharing this information.It was very nice blog to learn about magento

    ReplyDelete

 

Copyright @ 2017 HKBlog.