Magento 2 : After login need to redirect on same page instead of customer Dashboard
-
01-10-2020 - |
Question
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
.
Solution 2
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.
OTHER TIPS
We can config in Admin: STORES > Configuration > CUSTOMERS > Customer Configuration > Login Options > Redirect Customer to Account Dashboard after Logging in > No.
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