Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Return to Same Page after Log In

Return to Same Page after Log In

Locked

Views: 6,211

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
7 Feb 2007, 6:15 PM
#1
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

Return to Same Page after Log In

Pullin' a long shift this evenin' but goin' well. Nonetheless have this small query/ problem.
Setting: I have my shop set to a user must be logged in to see prices.
Picture this: User is NOT logged In and is browsing. He see's a product he likes and clicks on "log in" because he wants to know the price. He is directed to Log in page and after filling in details and pressing the "log in" button he is not returned to the product he is interested in but rather pushed to the main page! oh whoops. Major inconvenience becasue now he has ta find the product all over again.
Absolutely wanting: Is it possible that somehow the user is returned back to the previous page that he was on prior to log in rather than always being sent to the main page? Possibly by somehow setting up a "memory" variable (only guessing!!) or some other ingenious mechanism which zencart seems to be abounding with?

Thank you very much in advance,

Arpeggio

8 Feb 2007, 5:27 PM
#2
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: Return to Same Page after Log In

Yes, but it's gonna take some work...

  • The link to your login page has to become a form submission, with a hidden field containing the current page. You need to get fancy here because it's not just a file, but a get variable as well (index.php?main_page=[something])
  • On login page load, you need to look for that hidden variable and store it somewhere, a $_SESSION variable would probably be best.
  • Run the usual login stuff, and append some new code at the end to redirect the user to the page you previously stored.
9 Feb 2007, 9:57 AM
#3
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

Re: Return to Same Page after Log In

Holy Moly!! Well that's it for me then dear BlindSide. It is Strike 3 for me mate! I have 3 posts out there & all of them are requiring a technical programming skill well beyond my present and near future ability! I'm gonna have ta leave it like it is for now, make the changes absolutely needed for a "live" store, hopefully find customers and make the changes as my experience and self study progresses. Thank you for outlining the procedure to me. btw like ya caption "cleverly disguised as an adult" !! Thanks again. Arpeggio.

9 Feb 2007, 2:24 PM
#4
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: Return to Same Page after Log In

LOL :laugh:

It may not exactly be basic stuff, but it doesn't require an uber-coder either. It's probably easier than you think.

Getting the site up and running should definitely be your primary focus. You'll learn a lot just in doing so. Then you'll go and tweak something, then tweak a little more...you'll be writing mods in no time. :wink2:

I was named "Least Likely to Grow Up" in college.

10 Feb 2007, 12:52 PM
#5
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

Re: Return to Same Page after Log In

well ya gonna "lol" again dear Blindside 'cause i didn't know the meaning of "lol" so had ta look that up too!! ya got me lolling now too!
Thanks for ya vote of confidence. Incidently I did a search for "last page return php" etc on the net but no luck in getting some remotely related code. Yes, slowly does it and i'll get a'tweakin' after the page is up 'n runnin'. (the tweakin' is actually good fun!!)

"Least likely to grow up", ey?! Way ta go! What a compliment!! Reminds me of what the headmaster told Richard Branson" when he left school:
"You'll either be a criminal or a millionaire." !! LOL x 5!!
Another good one is:
"Parents fail when they try to be adults". oooh yeah!
Hai....jya...Tonikaku kore kara log in shimasu. oHanashi arigato. (Yes...well....Anyway gonna log in now. Thanks for chatting.)
Arpeggio.

10 Feb 2007, 5:25 PM
#6
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: Return to Same Page after Log In

ROFL!

(now go find that one :smartass: )

16 Jan 2009, 6:31 AM
#7
acechan avatar

acechan

New Zenner

Join Date:
Jan 2009
Posts:
1
Plugin Contributions:
0

Re: Return to Same Page after Log In

Hi!

I know I'm almost 2 years late, but as I had the same "issue", and I'm sure other people will have the same question as well, I'm posting what I've found (I've been searching for hours for a solution as BlindSide described, the scripts are complicated and tough to code so that they work in every situation, that's really a pain to do. This does NOT apply to the Zen Cart only, but this page appears on the first links of Google when you try to look for a clue).

Finally, I've found my own way to do it... in ONE code line : :smile:

But wait... it will only work if you use the php $SESSION technique to handle the user connection.

I work on that basis, which means that my x.php page shows basic contents to an anonymous user, and the SAME x.php page shows different extended contents depending on who's connected (using the 'session' way)... if a user visits this same page before logging in, then logs in, and then returns to that same page using the "back" button... miracle! It will work!

Does this talk to you? :cool:

Just use the javascript:history.go(-2) command on your login page, and you're done :D

22 May 2010, 8:52 AM
#8
deathman2006 avatar

deathman2006

New Zenner

Join Date:
Apr 2010
Location:
London, UK
Posts:
38
Plugin Contributions:
0

Re: Return to Same Page after Log In

What file do you need to edit to do this and where in the file do you put it?