Post by tora0515 » Wed Oct 17, 2012 9:30 am

Title about sums it up.

Something like this

If (customer came from a different page on my site) {
redirect back to that page;
} else {
redirect as usual;
}

Any ideas on this?

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by tora0515 » Thu Oct 18, 2012 12:42 pm

bump

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by Avvici » Thu Oct 18, 2012 12:44 pm

The first thing you do is set up the url in a session variable on the page you are trying to go to. For example if you are trying to go to your account section then in the account.php control file just add:

Code: Select all

$this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL'); 
Now in the login.php control just add the redirect after a successful login. Fill it in with the session variable:

Code: Select all

$this->redirect($this->session->data['redirect']);
or if you have ampersands involved

Code: Select all

$this->redirect(str_replace('&', '&', $this->request->post['redirect'])); 

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by tora0515 » Thu Oct 18, 2012 3:25 pm

Since I won't know what page the user will come from, I should put

Code: Select all

$this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL');
at the top of each tpl file, with account/account being changed?

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by philbydevil » Thu Oct 18, 2012 3:35 pm

I would suggest going with a "header login" extension. So, the customer can be on any page and log in directly from the header, staying on the same page after login (or being redirected to another page if you wish).

I use this one:
http://www.opencart.com/index.php?route ... on_id=2609

And I use the "stay on same page or redirect to whatever" redirects from this one:
http://www.opencart.com/index.php?route ... on_id=6979

The second one has several redirects set up for different pages (homepage, login page, logout page, everything else).

I Image cmd-f, cmd-c, cmd-v, cmd-z + vQmod.
My favourite page...
v1.5.4.1


User avatar
Active Member

Posts

Joined
Fri Dec 03, 2010 5:20 am
Location - Sunshine Coast, Australia

Post by Avvici » Fri Oct 19, 2012 12:23 am

Just use the controler that was given to you to use. You might as well learn how open cart does it by default (because it happens everywhere)

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by imdevlper18 » Sat Jun 09, 2018 2:58 am

An extension for this on the Opencart.
https://www.opencart.com/index.php?rout ... n_id=13998

It has 3 features: Page after login. Page after logout. Plus Strict Login.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Who is online

Users browsing this forum: No registered users and 19 guests