How to redirect to previous page after login?












0














I've set no on system configuration-> customer login configuration. But nothing's happen, it still direct to my account dashboard.



How to redirect to previous page after login?










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Have you this setting on website level and store level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:49










  • on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
    – syahidah humairoh
    Mar 29 '17 at 6:52












  • So You have done this changes in both website level and global level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:54










  • yes, I have done. But after i logged in, it still direct to account dashboard page
    – syahidah humairoh
    Mar 29 '17 at 7:01
















0














I've set no on system configuration-> customer login configuration. But nothing's happen, it still direct to my account dashboard.



How to redirect to previous page after login?










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Have you this setting on website level and store level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:49










  • on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
    – syahidah humairoh
    Mar 29 '17 at 6:52












  • So You have done this changes in both website level and global level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:54










  • yes, I have done. But after i logged in, it still direct to account dashboard page
    – syahidah humairoh
    Mar 29 '17 at 7:01














0












0








0







I've set no on system configuration-> customer login configuration. But nothing's happen, it still direct to my account dashboard.



How to redirect to previous page after login?










share|improve this question















I've set no on system configuration-> customer login configuration. But nothing's happen, it still direct to my account dashboard.



How to redirect to previous page after login?







magento-1.9 login redirect






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 12 '18 at 6:35









Ansar Husain

1,670217




1,670217










asked Mar 29 '17 at 6:47









syahidah humairohsyahidah humairoh

13814




13814





bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Have you this setting on website level and store level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:49










  • on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
    – syahidah humairoh
    Mar 29 '17 at 6:52












  • So You have done this changes in both website level and global level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:54










  • yes, I have done. But after i logged in, it still direct to account dashboard page
    – syahidah humairoh
    Mar 29 '17 at 7:01


















  • Have you this setting on website level and store level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:49










  • on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
    – syahidah humairoh
    Mar 29 '17 at 6:52












  • So You have done this changes in both website level and global level ??
    – Murtuza Zabuawala
    Mar 29 '17 at 6:54










  • yes, I have done. But after i logged in, it still direct to account dashboard page
    – syahidah humairoh
    Mar 29 '17 at 7:01
















Have you this setting on website level and store level ??
– Murtuza Zabuawala
Mar 29 '17 at 6:49




Have you this setting on website level and store level ??
– Murtuza Zabuawala
Mar 29 '17 at 6:49












on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
– syahidah humairoh
Mar 29 '17 at 6:52






on my website level, because there's no option to do that on my store level. @MurtuzaZabuawala
– syahidah humairoh
Mar 29 '17 at 6:52














So You have done this changes in both website level and global level ??
– Murtuza Zabuawala
Mar 29 '17 at 6:54




So You have done this changes in both website level and global level ??
– Murtuza Zabuawala
Mar 29 '17 at 6:54












yes, I have done. But after i logged in, it still direct to account dashboard page
– syahidah humairoh
Mar 29 '17 at 7:01




yes, I have done. But after i logged in, it still direct to account dashboard page
– syahidah humairoh
Mar 29 '17 at 7:01










4 Answers
4






active

oldest

votes


















0














You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :



 public function loginPostAction(){

if (!$this->_validateFormKey()) {
$this->_redirect('*/*/');
return;
}

if ($this->_getSession()->isLoggedIn()) {
$this->_redirect('wlc_business');
return;
}
$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 = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
$message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
$message = $e->getMessage();
break;
default:
$message = $e->getMessage();
}
$session->addError($message);
$session->setUsername($login['username']);
} 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.'));
}
}

// The adding code here
$this->_redirectReferer(); //redirect you to the previous page
$this->_redirect('/'); // redirect you to the home page
$this->_redirect('wishlist'); //redirect you to wishlist page for exemple
}





share|improve this answer





















  • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
    – syahidah humairoh
    Mar 31 '17 at 8:50










  • Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
    – PЯINCƏ
    Mar 31 '17 at 9:39





















0














You can customer_login observer. After customer has logged in, you can redirect the customer where you want.



Here is how to create observer for customer login
How to bind an action after customer login success using Magento?






share|improve this answer





























    0














    Set NO on System > Configuration > Customers > Customer Configuration > Login Options



    Then in your login.phtml files (both, persistent/customer/form and customer/form on your template folder), change the action of your <form> to:



    action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"


    But remember, DO NOT EDIT THE CORE! Create a custom extension to accomplish this job.



    Reference: https://stackoverflow.com/a/16099279/5810265






    share|improve this answer























    • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
      – syahidah humairoh
      Mar 31 '17 at 8:49










    • @syahidahhumairoh I think you will have a problem with core files!
      – Fayyaz Khattak
      Mar 31 '17 at 9:29



















    -2














    Please use below code to back to prev page after login



    <?php
    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $url = $objectManager->create('MagentoFrameworkUrlInterface');
    $loginUrl = $url->getUrl('customer/account/login', array('referer' => base64_encode($url->getCurrentUrl())));
    ?>
    <a href="<?php echo $loginUrl;?>">Login</a>





    share|improve this answer





















    • OP has asked for M1, not M2 :) but nice to know for m2...
      – JELLEJ
      May 8 '18 at 11:57










    • Dont use object manager even in M2
      – Sandipan S
      Jun 7 '18 at 9:43











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166664%2fhow-to-redirect-to-previous-page-after-login%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :



     public function loginPostAction(){

    if (!$this->_validateFormKey()) {
    $this->_redirect('*/*/');
    return;
    }

    if ($this->_getSession()->isLoggedIn()) {
    $this->_redirect('wlc_business');
    return;
    }
    $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 = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
    $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
    break;
    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
    $message = $e->getMessage();
    break;
    default:
    $message = $e->getMessage();
    }
    $session->addError($message);
    $session->setUsername($login['username']);
    } 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.'));
    }
    }

    // The adding code here
    $this->_redirectReferer(); //redirect you to the previous page
    $this->_redirect('/'); // redirect you to the home page
    $this->_redirect('wishlist'); //redirect you to wishlist page for exemple
    }





    share|improve this answer





















    • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
      – syahidah humairoh
      Mar 31 '17 at 8:50










    • Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
      – PЯINCƏ
      Mar 31 '17 at 9:39


















    0














    You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :



     public function loginPostAction(){

    if (!$this->_validateFormKey()) {
    $this->_redirect('*/*/');
    return;
    }

    if ($this->_getSession()->isLoggedIn()) {
    $this->_redirect('wlc_business');
    return;
    }
    $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 = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
    $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
    break;
    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
    $message = $e->getMessage();
    break;
    default:
    $message = $e->getMessage();
    }
    $session->addError($message);
    $session->setUsername($login['username']);
    } 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.'));
    }
    }

    // The adding code here
    $this->_redirectReferer(); //redirect you to the previous page
    $this->_redirect('/'); // redirect you to the home page
    $this->_redirect('wishlist'); //redirect you to wishlist page for exemple
    }





    share|improve this answer





















    • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
      – syahidah humairoh
      Mar 31 '17 at 8:50










    • Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
      – PЯINCƏ
      Mar 31 '17 at 9:39
















    0












    0








    0






    You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :



     public function loginPostAction(){

    if (!$this->_validateFormKey()) {
    $this->_redirect('*/*/');
    return;
    }

    if ($this->_getSession()->isLoggedIn()) {
    $this->_redirect('wlc_business');
    return;
    }
    $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 = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
    $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
    break;
    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
    $message = $e->getMessage();
    break;
    default:
    $message = $e->getMessage();
    }
    $session->addError($message);
    $session->setUsername($login['username']);
    } 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.'));
    }
    }

    // The adding code here
    $this->_redirectReferer(); //redirect you to the previous page
    $this->_redirect('/'); // redirect you to the home page
    $this->_redirect('wishlist'); //redirect you to wishlist page for exemple
    }





    share|improve this answer












    You have to rewrite in local loginPostAction() from app/code/core/Mage/Customer/controllers/AccountController.php to app/code/local/Customer/controllers/AccountController.php Then you put this :



     public function loginPostAction(){

    if (!$this->_validateFormKey()) {
    $this->_redirect('*/*/');
    return;
    }

    if ($this->_getSession()->isLoggedIn()) {
    $this->_redirect('wlc_business');
    return;
    }
    $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 = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']);
    $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
    break;
    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
    $message = $e->getMessage();
    break;
    default:
    $message = $e->getMessage();
    }
    $session->addError($message);
    $session->setUsername($login['username']);
    } 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.'));
    }
    }

    // The adding code here
    $this->_redirectReferer(); //redirect you to the previous page
    $this->_redirect('/'); // redirect you to the home page
    $this->_redirect('wishlist'); //redirect you to wishlist page for exemple
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 30 '17 at 8:45









    PЯINCƏPЯINCƏ

    7,75131137




    7,75131137












    • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
      – syahidah humairoh
      Mar 31 '17 at 8:50










    • Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
      – PЯINCƏ
      Mar 31 '17 at 9:39




















    • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
      – syahidah humairoh
      Mar 31 '17 at 8:50










    • Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
      – PЯINCƏ
      Mar 31 '17 at 9:39


















    I don't know why when I set "no" my login page is not give an alert when I insert wrong password
    – syahidah humairoh
    Mar 31 '17 at 8:50




    I don't know why when I set "no" my login page is not give an alert when I insert wrong password
    – syahidah humairoh
    Mar 31 '17 at 8:50












    Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
    – PЯINCƏ
    Mar 31 '17 at 9:39






    Either the problem comes from the theme, or you have removed the block that displays the messages$this->getMessagesBlock()->getGroupedHtml(); or the controller if you had modified it, please compare with my controller.
    – PЯINCƏ
    Mar 31 '17 at 9:39















    0














    You can customer_login observer. After customer has logged in, you can redirect the customer where you want.



    Here is how to create observer for customer login
    How to bind an action after customer login success using Magento?






    share|improve this answer


























      0














      You can customer_login observer. After customer has logged in, you can redirect the customer where you want.



      Here is how to create observer for customer login
      How to bind an action after customer login success using Magento?






      share|improve this answer
























        0












        0








        0






        You can customer_login observer. After customer has logged in, you can redirect the customer where you want.



        Here is how to create observer for customer login
        How to bind an action after customer login success using Magento?






        share|improve this answer












        You can customer_login observer. After customer has logged in, you can redirect the customer where you want.



        Here is how to create observer for customer login
        How to bind an action after customer login success using Magento?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 16 '18 at 22:27









        Ledian HymetllariLedian Hymetllari

        71639




        71639























            0














            Set NO on System > Configuration > Customers > Customer Configuration > Login Options



            Then in your login.phtml files (both, persistent/customer/form and customer/form on your template folder), change the action of your <form> to:



            action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"


            But remember, DO NOT EDIT THE CORE! Create a custom extension to accomplish this job.



            Reference: https://stackoverflow.com/a/16099279/5810265






            share|improve this answer























            • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
              – syahidah humairoh
              Mar 31 '17 at 8:49










            • @syahidahhumairoh I think you will have a problem with core files!
              – Fayyaz Khattak
              Mar 31 '17 at 9:29
















            0














            Set NO on System > Configuration > Customers > Customer Configuration > Login Options



            Then in your login.phtml files (both, persistent/customer/form and customer/form on your template folder), change the action of your <form> to:



            action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"


            But remember, DO NOT EDIT THE CORE! Create a custom extension to accomplish this job.



            Reference: https://stackoverflow.com/a/16099279/5810265






            share|improve this answer























            • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
              – syahidah humairoh
              Mar 31 '17 at 8:49










            • @syahidahhumairoh I think you will have a problem with core files!
              – Fayyaz Khattak
              Mar 31 '17 at 9:29














            0












            0








            0






            Set NO on System > Configuration > Customers > Customer Configuration > Login Options



            Then in your login.phtml files (both, persistent/customer/form and customer/form on your template folder), change the action of your <form> to:



            action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"


            But remember, DO NOT EDIT THE CORE! Create a custom extension to accomplish this job.



            Reference: https://stackoverflow.com/a/16099279/5810265






            share|improve this answer














            Set NO on System > Configuration > Customers > Customer Configuration > Login Options



            Then in your login.phtml files (both, persistent/customer/form and customer/form on your template folder), change the action of your <form> to:



            action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"


            But remember, DO NOT EDIT THE CORE! Create a custom extension to accomplish this job.



            Reference: https://stackoverflow.com/a/16099279/5810265







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 7 '18 at 9:41









            Teja Bhagavan Kollepara

            2,94841847




            2,94841847










            answered Mar 30 '17 at 8:04









            Fayyaz KhattakFayyaz Khattak

            1,491922




            1,491922












            • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
              – syahidah humairoh
              Mar 31 '17 at 8:49










            • @syahidahhumairoh I think you will have a problem with core files!
              – Fayyaz Khattak
              Mar 31 '17 at 9:29


















            • I don't know why when I set "no" my login page is not give an alert when I insert wrong password
              – syahidah humairoh
              Mar 31 '17 at 8:49










            • @syahidahhumairoh I think you will have a problem with core files!
              – Fayyaz Khattak
              Mar 31 '17 at 9:29
















            I don't know why when I set "no" my login page is not give an alert when I insert wrong password
            – syahidah humairoh
            Mar 31 '17 at 8:49




            I don't know why when I set "no" my login page is not give an alert when I insert wrong password
            – syahidah humairoh
            Mar 31 '17 at 8:49












            @syahidahhumairoh I think you will have a problem with core files!
            – Fayyaz Khattak
            Mar 31 '17 at 9:29




            @syahidahhumairoh I think you will have a problem with core files!
            – Fayyaz Khattak
            Mar 31 '17 at 9:29











            -2














            Please use below code to back to prev page after login



            <?php
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $url = $objectManager->create('MagentoFrameworkUrlInterface');
            $loginUrl = $url->getUrl('customer/account/login', array('referer' => base64_encode($url->getCurrentUrl())));
            ?>
            <a href="<?php echo $loginUrl;?>">Login</a>





            share|improve this answer





















            • OP has asked for M1, not M2 :) but nice to know for m2...
              – JELLEJ
              May 8 '18 at 11:57










            • Dont use object manager even in M2
              – Sandipan S
              Jun 7 '18 at 9:43
















            -2














            Please use below code to back to prev page after login



            <?php
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $url = $objectManager->create('MagentoFrameworkUrlInterface');
            $loginUrl = $url->getUrl('customer/account/login', array('referer' => base64_encode($url->getCurrentUrl())));
            ?>
            <a href="<?php echo $loginUrl;?>">Login</a>





            share|improve this answer





















            • OP has asked for M1, not M2 :) but nice to know for m2...
              – JELLEJ
              May 8 '18 at 11:57










            • Dont use object manager even in M2
              – Sandipan S
              Jun 7 '18 at 9:43














            -2












            -2








            -2






            Please use below code to back to prev page after login



            <?php
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $url = $objectManager->create('MagentoFrameworkUrlInterface');
            $loginUrl = $url->getUrl('customer/account/login', array('referer' => base64_encode($url->getCurrentUrl())));
            ?>
            <a href="<?php echo $loginUrl;?>">Login</a>





            share|improve this answer












            Please use below code to back to prev page after login



            <?php
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $url = $objectManager->create('MagentoFrameworkUrlInterface');
            $loginUrl = $url->getUrl('customer/account/login', array('referer' => base64_encode($url->getCurrentUrl())));
            ?>
            <a href="<?php echo $loginUrl;?>">Login</a>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 16 '18 at 18:34









            Sunil PatelSunil Patel

            1,2881612




            1,2881612












            • OP has asked for M1, not M2 :) but nice to know for m2...
              – JELLEJ
              May 8 '18 at 11:57










            • Dont use object manager even in M2
              – Sandipan S
              Jun 7 '18 at 9:43


















            • OP has asked for M1, not M2 :) but nice to know for m2...
              – JELLEJ
              May 8 '18 at 11:57










            • Dont use object manager even in M2
              – Sandipan S
              Jun 7 '18 at 9:43
















            OP has asked for M1, not M2 :) but nice to know for m2...
            – JELLEJ
            May 8 '18 at 11:57




            OP has asked for M1, not M2 :) but nice to know for m2...
            – JELLEJ
            May 8 '18 at 11:57












            Dont use object manager even in M2
            – Sandipan S
            Jun 7 '18 at 9:43




            Dont use object manager even in M2
            – Sandipan S
            Jun 7 '18 at 9:43


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166664%2fhow-to-redirect-to-previous-page-after-login%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            An IMO inspired problem

            Management

            Has there ever been an instance of an active nuclear power plant within or near a war zone?