1

How to redirect to same page viewed page after login in opencart 3.0.2.0?

Any one please help me

Thanks

Navid
  • 65
  • 10
  • store the destination as a session variable and redirect there once login succeeds. – But those new buttons though.. May 09 '18 at 19:40
  • 2
    Possible duplicate of [Opencart Login to Previous Viewed Page After Logging in?](https://stackoverflow.com/questions/16983707/opencart-login-to-previous-viewed-page-after-logging-in) – Ziauz May 09 '18 at 20:36
  • That question is about the opecart 1.5.6.4 but my question relates to the opencart version 3.0.2.0. – Navid May 11 '18 at 17:16
  • Do you know where it always supposed to be redirected or it will be distinct per request? oc versions is not so distinct that u cannot use 1.5 answer in 3.x with minor changes it should work – Nerius Jok May 12 '18 at 15:04
  • Maybe show us the effort you put into this by relaying to us what you tried so far, then you may get more feedback. The answer still lies in catalog/controller/account/login.php - FYI. You just need to rework the code for the current version you are using. You might also want to think about how you wish to redirect after a customer logs off, too - just some food for thought. – Nancy May 15 '18 at 04:47

1 Answers1

1

You would need to edit catalog/controller/account/login.php

find for this

if ($this->customer->isLogged()) {
        $this->response->redirect($this->url->link('account/account', '', true));
    }

and replace it by

 if ($this->customer->isLogged()) {  
     $this->response->redirect($this->url->link('account/account', '', 'ture'));
}elseif(!isset($this->session->data['redirect']) && isset($_SERVER['HTTP_REFERER'])){
$this->session->data['redirect'] = $_SERVER['HTTP_REFERER'];
}

Hope this might help You

Ziauz
  • 773
  • 4
  • 22