1

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');
$session->setAfterAuthUrl("/checkout/onepage/");

I want to redirect my account page.

Any idea why this is not working ?

1

2 Answers 2

0

You can try below working code.

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

        $session->setBeforeAuthUrl('');
    }
3
  • Now I am redirect to cart page . 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. Sep 26, 2016 at 9:55
  • In my case I changed the custom/page with ''checkout/onepage'. and I am still redirected to cart Sep 26, 2016 at 10:02
0

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.

2
  • I want to redirect to a custom URL. If I set this to yes, will it work ? Sep 26, 2016 at 9:44
  • @AttilaNaghi no sorry, I thought you wanted to redirect to the account page. 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.