I'm having some difficulties with redirecting a customer, after they login. I'm using the


event, which is firing my specified function properly.

Here is my function:

public function customerLoginObserve($observer)
    //customer is able to login, but no redirection occurs
    $url = 'http://myurl.com';
    $session = Mage::getSingleton('customer/session');

    // Also tried the line below, the UI freezes, and when refreshing the page, customer is logged in:

    //This one also did not work in the login event (freezes UI), but when fired from 
    //other events, works as expected.

EDIT: There doesn't seem to be any errors in the system.log and exception.log If I try to redirect with any of the sendResponse(), that's where the code stops.

Here are a few links that I've looked into, which did not work for me:

Redirect user after login

Magento redirect from all pages if not logged in

Any help appreciated!

  • We will need to see the config for the event I guess. Also is your class being called? Maybe put in some debug to see if it is reaching the observer – David Manners Apr 20 '15 at 18:54
  • hello David, the observer is being called without problems. I've tried logging throughout my function. If I use the setRedirect($url), that's when things seem to go wrong, and logs after that don't get outputted. – bamboo_inside Apr 20 '15 at 18:57

I think what you are missing is to send the response after setting the url. This can be done as follows.

Mage::app()->getFrontController()->getResponse()->setRedirect('Your URL');
  • Thanks David, but that still freezes the UI, without redirecting in my case... still no log errors as well, even though the code runs up to those lines without problems. – bamboo_inside Apr 20 '15 at 20:04
  • @bamboo_inside what do you mean by freezes the UI? You might also want to check the general php logs as well and the Magento logs – David Manners Apr 21 '15 at 7:41

Your Answer

