Sending Shoppers Back Where They Were After Logging In

Sending Shoppers Back Where They Were After Logging In

By default Magento 1 drops customers on their account dashboard after logging in, which interrupts shopping. A few settings and one snippet fix that.

Return to the previous page

Go to System > Configuration > Customers > Customer Configuration > Login Options and set Redirect Customer to Account Dashboard after Logging in to No.

Require login for a page

Place this at the top of a template to send guests to the login screen, then back again afterwards:

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

Stay on the page after add to cart

In Sales > Checkout, set After Adding a Product Redirect to Shopping Cart to No, so shoppers can keep browsing.

Heads up: this guide applies to Magento 1, which stopped receiving official security updates in June 2020. If your store still runs it, plan a move to Magento 2 or Adobe Commerce soon. We can help with the migration.

Need a second pair of eyes on this? Our team handles Magento development every week. See how we can help.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.