I'm trying to redirect a user back to the page he was previously on after he has logged in. So I did this in my controller:
$session = Mage::getSingleton('customer/session');
$session->setCustomerAsLoggedIn($customer);
$this->_redirectUrl($session->getBeforeAuthUrl());
However, it seems like $session->getBeforeAuthUrl()
is always returning null
and it ends up redirecting to an blank page.
How can I redirect a user back to the page he was previously on after he has logged in?
$session->setBeforeAuthUrl($this->_getRefererUrl());
inMage_Customer_AccountController::loginAction()
first. Also see magento.stackexchange.com/questions/29580/… – kiatng May 25 '16 at 4:19