News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Remember location when logging in.

Started by Burpee, February 10, 2005, 07:25:00 AM

Previous topic - Next topic

Burpee

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.

Oldiesmann

Michael Eshom
Christian Metal Fans

[Unknown]

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]

Burpee


[Unknown]

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]

Jerry

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."

Burpee

Quote from: [Unknown] 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]

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.

Oldiesmann

How about a "return to this page" checkbox? That would please everyone.
Michael Eshom
Christian Metal Fans

xenovanis

Quote from: Oldiesmann on February 12, 2005, 08:48:23 PM
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."

NukeWorker.com

Check box defaulted to on.

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

[Unknown]

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

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:

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


-[Unknown]

ryanbsoftware

Quote from: [Unknown] on March 01, 2005, 04:30:25 AM
Fine, whatever... find this in LogInOut.php:

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:

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. ;)

Oldiesmann

Quote from: RyanB on March 01, 2005, 01:14:01 PM
Quote from: [Unknown] on March 01, 2005, 04:30:25 AM
Fine, whatever... find this in LogInOut.php:

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:

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
Christian Metal Fans

sledgeweb

#13
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.

NukeWorker.com

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.

[Unknown]

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]

NukeWorker.com

#16
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.

sledgeweb

Quote from: [Unknown] 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]

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?

[Unknown]

Add to Settings.php, before the ?>:

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

-[Unknown]

rmurdo


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


Quote from: [Unknown] on March 01, 2005, 04:30:25 AM
Fine, whatever... find this in LogInOut.php:

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:

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


-[Unknown]

Advertisement: