I am using the customer_login event for my observer. I am trying to redirect my user after login.

I used below code.

$session = Mage::getSingleton('customer/session');

I want to redirect my account page.

Any idea why this is not working ?

  • If I leave : $session->setAfterAuthUrl("myurl/checkout/"); it works !!. If I leave like this: $session->setAfterAuthUrl("myurl/checkout/onepage"); I am redirected to my account. Please someone explain me why ? :D Commented Sep 26, 2016 at 10:24

2 Answers 2


You can try below working code.

 public function setRedirectOnLogin(){
        $session = Mage::getSingleton('customer/session');
        if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') === false)

  • Now I am redirect to cart page . Commented Sep 26, 2016 at 9:43
  • $session->setBeforeAuthUrl(Mage::getUrl('custom/page')); $session->setAfterAuthUrl(Mage::getUrl('custom/page')); change the url as per the Route. Commented Sep 26, 2016 at 9:55
  • In my case I changed the custom/page with ''checkout/onepage'. and I am still redirected to cart Commented Sep 26, 2016 at 10:02

Magento 1 supports automatic redirection to the account page by default. To enable that, all you need to do is go to System > Configuration > Customer Configuration > Login Options and set Redirect Customer to Account Dashboard after Logging in to Yes.

  • I want to redirect to a custom URL. If I set this to yes, will it work ? Commented Sep 26, 2016 at 9:44
  • @AttilaNaghi no sorry, I thought you wanted to redirect to the account page. Commented Sep 26, 2016 at 9:47

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.