Advertisement:

Author Topic: Remember location when logging in.  (Read 40891 times)

Offline Burpee

  • SMF Friend
  • Sophist Member
  • *
  • Posts: 1,298
  • Gender: Male
    • Mafan.nl
Remember location when logging in.
« on: February 10, 2005, 07:25:00 AM »
Currently, when you log in from any page within the forum (such as this thread), you are automatically referred back to the forum index.
It would make a lot more sense to remember where you logged in and to send you back to that page, but now as a logged in user.
When people log in, they don't want to be referred back to the index, they're usually logging in because they saw something on a certain page and wish to reply to it, vote or something else. It's illogical and annoying to be sent back to the index when logging in.

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Remember location when logging in.
« Reply #1 on: February 11, 2005, 12:46:50 PM »
I agree.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Remember location when logging in.
« Reply #2 on: February 12, 2005, 04:49:16 AM »
This was the original behavior but it caused a lot of problems and so things were moved back so it only did topics and boards, and only from the login page not the quick login.

-[Unknown]

Offline Burpee

  • SMF Friend
  • Sophist Member
  • *
  • Posts: 1,298
  • Gender: Male
    • Mafan.nl
Re: Remember location when logging in.
« Reply #3 on: February 12, 2005, 05:13:11 PM »
Any chance of fixing those problems?

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Remember location when logging in.
« Reply #4 on: February 12, 2005, 06:35:27 PM »
The problems were people getting redirected back to things they DIDN'T want to be redirected back to.  You may see it now and think you want it, but people complained left and right when it did exactly what you're asking for.

-[Unknown]

Offline Jerry

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,903
  • Gender: Male
  • What? I can't hear you over my awesomeness!!
    • PlanetSMF
Re: Remember location when logging in.
« Reply #5 on: February 12, 2005, 06:42:19 PM »
maybe it would make a good mod instead? I also would like this :)
- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Offline Burpee

  • SMF Friend
  • Sophist Member
  • *
  • Posts: 1,298
  • Gender: Male
    • Mafan.nl
Re: Remember location when logging in.
« Reply #6 on: February 12, 2005, 08:39:32 PM »
The problems were people getting redirected back to things they DIDN'T want to be redirected back to. You may see it now and think you want it, but people complained left and right when it did exactly what you're asking for.

-[Unknown]

If you get redirected to the place you came from, it's good isn't it?
I can't really imagine people complaining about something like that to be honest.

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Remember location when logging in.
« Reply #7 on: February 12, 2005, 08:48:23 PM »
How about a "return to this page" checkbox? That would please everyone.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline xenovanis

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,988
  • Gender: Female
Re: Remember location when logging in.
« Reply #8 on: February 13, 2005, 02:22:06 AM »
How about a "return to this page" checkbox? That would please everyone.

I'd like that!
"Insanity: doing the same thing over and over again and expecting different results."

Offline NukeWorker.com

  • Full Member
  • ***
  • Posts: 416
  • Gender: Male
  • I love NukeWorker.com
    • Nuclear Jobs Pictures News
Re: Remember location when logging in.
« Reply #9 on: February 28, 2005, 09:59:51 AM »
Check box defaulted to on.

I have been hounded by my users for years for this feature.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Remember location when logging in.
« Reply #10 on: March 01, 2005, 04:30:25 AM »
Fine, whatever... find this in LogInOut.php:

Code: [Select]
if (isset($_SESSION['old_url']) && (strstr($_SESSION['old_url'], 'board=') !== false || strstr($_SESSION['old_url'], 'topic=') !== false))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

Replace:

Code: [Select]
if (isset($_SESSION['old_url']))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

-[Unknown]

ryanbsoftware

  • Guest
Re: Remember location when logging in.
« Reply #11 on: March 01, 2005, 01:14:01 PM »
Fine, whatever... find this in LogInOut.php:

Code: [Select]
if (isset($_SESSION['old_url']) && (strstr($_SESSION['old_url'], 'board=') !== false || strstr($_SESSION['old_url'], 'topic=') !== false))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

Replace:

Code: [Select]
if (isset($_SESSION['old_url']))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

-[Unknown]

thanks, [unknown] i too agree with this, this should be moved to tip/tricks. ;)

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Remember location when logging in.
« Reply #12 on: March 01, 2005, 03:55:01 PM »
Fine, whatever... find this in LogInOut.php:

Code: [Select]
if (isset($_SESSION['old_url']) && (strstr($_SESSION['old_url'], 'board=') !== false || strstr($_SESSION['old_url'], 'topic=') !== false))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

Replace:

Code: [Select]
if (isset($_SESSION['old_url']))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

-[Unknown]

thanks, [unknown] i too agree with this, this should be moved to tip/tricks. ;)

Done.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline sledgeweb

  • Semi-Newbie
  • *
  • Posts: 90
Re: Remember location when logging in.
« Reply #13 on: March 10, 2005, 04:44:24 PM »
How can I incorporate this into non forum pages? I have a nav bar at the top of my website that let's people login on any page. I tried setting: $_SESSION['old_url'] = 'http://mywebsiteurl.com' , but it doesn't work, it goes to the forum index after login/logout.

I'd like it so when they login in, they just go back to the page they logged in from, even if it isn't a forum page. Based on the code snippet above, it looks like setting $_SESSION['old_url'] should do the trick, but it doesn't seem to be working. It is working if I login in on a forum page, but not if it is a non-forum page.

Also, on the forum pages, it only works correctly on login. Logout always takes me back to the forum index.
« Last Edit: March 10, 2005, 04:46:13 PM by sledgeweb »

Offline NukeWorker.com

  • Full Member
  • ***
  • Posts: 416
  • Gender: Male
  • I love NukeWorker.com
    • Nuclear Jobs Pictures News
Re: Remember location when logging in.
« Reply #14 on: March 10, 2005, 06:46:37 PM »
I would like to make this work with the quick login. This same code is not in the theme.index.php.  What would I change there.  The quick login is the one that people would be more likely to use when they wanted to return to their current location, as the login box is on the same page.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Remember location when logging in.
« Reply #15 on: March 11, 2005, 07:27:27 AM »
This won't work for the quick login or across subdomains.  SSI.php must be loaded at the top of the page for it to work outside the forum.

Just set $_SESSION['login_url'] for other uses.

-[Unknown]

Offline NukeWorker.com

  • Full Member
  • ***
  • Posts: 416
  • Gender: Male
  • I love NukeWorker.com
    • Nuclear Jobs Pictures News
Re: Remember location when logging in.
« Reply #16 on: March 11, 2005, 02:00:17 PM »
Will $_SESSION['login_url'] work for the quick login box?

I have it working on my home page with the ssi, and its fantastic.

Also, will the ssi work in my coppermine template?  I was able to get ssi_welcome, and several others to work fine by placing them in the custom header section of the theme.php.
« Last Edit: March 11, 2005, 02:04:48 PM by NukeWorker.com »

Offline sledgeweb

  • Semi-Newbie
  • *
  • Posts: 90
Re: Remember location when logging in.
« Reply #17 on: March 11, 2005, 04:30:05 PM »
This won't work for the quick login or across subdomains.  SSI.php must be loaded at the top of the page for it to work outside the forum.

Just set $_SESSION['login_url'] for other uses.

-[Unknown]

I've also noticed, it makes a big difference if someone puts the "www" on the url or not. On my non-forum pages, if I try to login, and the user has entered the URL without the "www." is causes an error saying it couldn't verify the referring URL. How can I make it work and ignore whether or not the www. is before the domain name in the URL?

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Remember location when logging in.
« Reply #18 on: March 11, 2005, 04:40:10 PM »
Add to Settings.php, before the ?>:

ini_set('session.cookie_domain', '.yourdomain.com');

-[Unknown]

Offline rmurdo

  • Newbie
  • *
  • Posts: 1
Re: Remember location when logging in.
« Reply #19 on: February 25, 2007, 01:23:58 AM »

Hi all, it looks like the code may have changed since this was posted.  Anyone have a more current method of returning you to the page you logged in from?

Thanks,

Robert


Fine, whatever... find this in LogInOut.php:

Code: [Select]
if (isset($_SESSION['old_url']) && (strstr($_SESSION['old_url'], 'board=') !== false || strstr($_SESSION['old_url'], 'topic=') !== false))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

Replace:

Code: [Select]
if (isset($_SESSION['old_url']))
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);

-[Unknown]