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 ?


You can try below working code.

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

| improve this answer | |
  • Now I am redirect to cart page . – Attila Naghi Sep 26 '16 at 9:43
  • $session->setBeforeAuthUrl(Mage::getUrl('custom/page')); $session->setAfterAuthUrl(Mage::getUrl('custom/page')); change the url as per the Route. – Krishna ijjada Sep 26 '16 at 9:55
  • In my case I changed the custom/page with ''checkout/onepage'. and I am still redirected to cart – Attila Naghi Sep 26 '16 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.

| improve this answer | |
  • I want to redirect to a custom URL. If I set this to yes, will it work ? – Attila Naghi Sep 26 '16 at 9:44
  • @AttilaNaghi no sorry, I thought you wanted to redirect to the account page. – Raphael at Digital Pianism Sep 26 '16 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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