I have two themes e.g. mobile and desktop.
For mobile theme I have separated the first step of the checkout process i.e. Login step to different page.
page no.1-from basket page a person goto the login page(login or checkout as guest).
So here the file present in "chekout/onepage/login.phtml" is getting rendered.

page no.2-The next step is to calculate delivery method and delivery options in a page.
page no.3-Then the payment method page and finally the checkout process.

So I want when a person go to the page no. 1 (i.e. login page) and give the email and password and click the login button , then the person will redirected to the page no.2(delivery method and options).

But it Redirects to the account dashboard page.

Below is the code for the login and redirect which is located at ..

public function loginPostAction()
    if ($this->_getSession()->isLoggedIn()) {
    $session = $this->_getSession();

    if ($this->getRequest()->isPost()) {
        $login = $this->getRequest()->getPost('login');
        if (!empty($login['username']) && !empty($login['password'])) {
            try {
                $session->login($login['username'], $login['password']);
                if ($session->getCustomer()->getIsJustConfirmed()) {
                    $this->_welcomeCustomer($session->getCustomer(), true);
            } catch (Mage_Core_Exception $e) {
                switch ($e->getCode()) {
                    case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                        $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
                        $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
                    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                        $message = $e->getMessage();
                        $message = $e->getMessage();
            } catch (Exception $e) {
                // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
        } else {
            $session->addError($this->__('Login and password are required.'));


 * Define target URL and redirect customer after logging in
protected function _loginPostRedirect()
    $session = $this->_getSession();

    if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
        // Set default URL to redirect customer to
        // Redirect customer to the last page visited after logging in
        if ($session->isLoggedIn()) {echo "gone";exit;
            if (!Mage::getStoreConfigFlag(
            )) {
                $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
                if ($referer) {
                    // Rebuild referer URL to handle the case when SID was changed
                    $referer = Mage::getModel('core/url')
                    if ($this->_isUrlInternal($referer)) {
            } else if ($session->getAfterAuthUrl()) {
        } else {echo "go";exit;
    } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
    } else {
        if (!$session->getAfterAuthUrl()) {
        if ($session->isLoggedIn()) {


How can I change the redirection to a particular page after login step for mobile theme only ?
Is it possible to redirect to different url for different theme in a single store from the same method ?
Is it required to override the customer module ?
How can I override the redirect method of customer to redirect to particular page ?

  • see this post, you can use an observer after login event May 26, 2017 at 1:52

2 Answers 2


go to persistent/customer/form/login.phtml or customer/form/login.phtml and add the following into the form:

<?php if (Mage::getDesign()->getTheme('frontend') == "your_mobile_theme"): ?>
    <input type="hidden" name="referer_url" value="your_page_url"/>
<?php endif; ?>

please let me know if it's ok

  • 1
    But the login form I am talking about is supposed to be present at..mypackage/iphone/template/checkout/onepage/login.phtml Jan 21, 2016 at 6:59

You first need to set "Redirect Customer to Account Dashboard after Logging in" to "No" as shown in below screenshot.

enter image description here

And in the "checkout/onepage/login.phtml" change form action as mentioned below.

<form action="<?php echo $this->getUrl('customer/account/loginPost',array('referer' => Mage::helper('core')->urlEncode('page no.2 url'))) ?>" method="post">

Here you can do by another way.

write a basic custome module and register an event for customer_login in the frontend area as below


After that, create an observer class and write below function.

public function redirectLoginLogin($observer)
  $session = Mage::getSingleton('customer/session');
  if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') ===   false)
    $session->setAfterAuthUrl('Your page 2 url');

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.