2026 Executive BenchmarkMid-Market Enterprise Modernization: How leaders across unify Commerce, Odoo ERP & AI in 90 days.
MAGENTO COMMERCE

Redirect Customer to Previous Page After Login

Configuration Settings – Login to admin panel – Go to System -> Configuration -> CUSTOMERS -> Customer Configuration -> Login Options – Set: Redirect Customers to Account Dashboard...

Akshar Group Technologies
Dec 25, 2020
1 min read
Verified Source

Configuration Settings : Login to admin panel : Go to System -> Configuration -> CUSTOMERS -> Customer Configuration -> Login Options : Set: Redirect Customers to Account Dashboard after Loggin in = No : You can see in comments for this field: Customer will stay on the current page if No is selected. 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 to customer login page

php
if(!Mage::helper('customer')->isLoggedIn()){
Mage::getSingleton('customer/session')
->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
$this->_redirect('customer/account/login');
}
Show a login link for non-logged in customers
code
if(!Mage::helper('customer')->isLoggedIn()){
Mage::getSingleton('customer/session')
->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
echo'
Please Login to view the page.
Share this playbook
LET'S BUILD WHAT'S NEXT

What's Holding Your Business Back?

Tell us where you want to go, what's getting in the way, and we'll help you figure out the technology to get there.

No sales pitch. Confidential strategic advisory.