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.

1

2 Answers 2

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

5
  • 2
    I already set this to NO. But its not working for me. Aug 12, 2016 at 10:50
  • You choose correct store view or any customized? Aug 12, 2016 at 10:53
  • 1
    I already checked all these setting and all are proper. If you have any idea which methods is responsible for this setting for redirect so that I can check there for the value of this setting ? Aug 12, 2016 at 10:55
  • I updated some useful methods. You should take a look. Aug 13, 2016 at 11:32
  • When I enable the guest checkout its working fine. Is it possible to set this only for customer ? Aug 16, 2016 at 6:04
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.

3
  • Not working, still have the referer link.... Jul 26, 2018 at 13:19
  • 1
    No need to enable Guest Checkout. Just flush the cache properly and maybe browser cache as well.
    – Abid Malik
    Aug 28, 2019 at 9:32
  • lol, why you have to enable guest checkout, it has nothing to do with it
    – Black
    Nov 6, 2020 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.