0

After login redirect user on previous page from front-end.

I am using the login pop-up and all default functionality. Also the Admin configuration Redirect Customer to Account is set as No. But it redirect me on Customer Dashboard.

Ashish Jagnani
  • 6,266
  • 7
  • 33
  • 70

2 Answers2

9

We can config in Admin: STORES > Configuration > CUSTOMERS > Customer Configuration > Login Options > Redirect Customer to Account Dashboard after Logging in > No.

enter image description here

When enabled this config, the login url will have a referer param to base64 encode url, like: http://{website_url}/customer/account/login/referer/aHR0cDovL2xvY2FsaG9zdC9tYWdlMjE=/

Technically, we should take a look:

vendor/magento/module-customer/Controller/Account/LoginPost.php

 public function execute()
 {
        ......
        return $this->accountRedirect->getRedirect();
 }

vendor/magento/module-customer/Model/Account/Redirect.php

/**
 * Retrieve redirect
 *
 * @return ResultRedirect|ResultForward
 */
public function getRedirect()
{
     ......
}

UPDATE: Please delete your local storage, this feature will work well. Please read more here.

Magento Version:

-Magento version 2.1.0

Khoa TruongDinh
  • 32,054
  • 11
  • 88
  • 155
3

Set config setting in Admin:

STORES > Configuration > CUSTOMERS > Customer Configuration > Login Options > Redirect Customer to Account Dashboard after Logging in > No.

Also we have to enable Guest checkout.

Ashish Jagnani
  • 6,266
  • 7
  • 33
  • 70