I'm having some difficulties with redirecting a customer, after they login.
I'm using the
<customer_login>
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');
$session->setAfterAuthUrl($url);
$session->setBeforeAuthUrl('');
// Also tried the line below, the UI freezes, and when refreshing the page, customer is logged in:
//$observer->getEvent()->getFront()->getResponse()->setRedirect($url)->sendResponse();
//This one also did not work in the login event (freezes UI), but when fired from
//other events, works as expected.
//$observer->getEvent()->getResponse()->setRedirect($url)->sendResponse();
//exit;
}
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:
Magento redirect from all pages if not logged in
Any help appreciated!
Best Answer
I think what you are missing is to send the response after setting the url. This can be done as follows.