News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

login redirecting

Started by King Dingeling, July 16, 2007, 04:43:43 PM

Previous topic - Next topic

King Dingeling

I've searched all of the forum (finding lots of solutions, but none works after 1.1.3 update) for a reason as  to why my login redirecting stopped working after I updated to 1.1.3.

when I ran 1.1.2 I used the following code with success (not the standard ssi way I know, but it worked none the less)
<form id="form1" method="post" action="forum/index.php?action=login2&amp;front_url=index.php" accept-charset="ISO-8859-1">
at my mainpage, and edited the loginout.php file a bit so it read
// Set the login_url if it's not already set.
if (empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
$_SESSION['login_url'] = $_SESSION['old_url'];
if (isset($_GET["front_url"])){
$_SESSION['login_url'] = "mymainpage.com";
}

after 1.1.3 that doesn't work anymore. Then I tried the standard ssi way of doing it ie.
<?php
require("forum/SSI.php");
$_SESSION['login_url'] = "http://mymainpage.com";
ssi_login();

or

ssi_login('mymainpage.com');
?>

but none of them seems to work either, no matter what I try, I'm redirected to the index page of the forum, after successful login. as you might have figured I'm interested in making it reload the mainpage of my website instead.

Anyone want to enlighten me, as I seem to have run out of ideas.
As it worked pre 1.1.3 I can't imagine that any of my forum settings should be wrong, as it's the exact same, but just to clear the air, I've got 'Enable local storage of cookies' and 'Use subdomain independent cookies' unticked, andI've tested with 'Use database driven sessions' on and off to no avail at all.

Again, I searched and looked through tons of pages concerning almost similar problems, but none seemed to do me any good.

Any help appreciated as it's starting to drive me nuts.

KD

radj

having the same problem with this one, too.


radj

uhm.. so wats our resolution on this? hihihi.

mertensberg

If you want to redirect the user to an existing action page (like profile or something else), this quick workaround might help.

Edit LogInOut.php this way (insert $_SESSION['login_url'] = 'action=your_action'; after the global statements):


function Login2()
{
global $txt, $db_prefix, $scripturl, $user_info, $user_settings;
global $cookiename, $maintenance, $ID_MEMBER, $modSettings, $context, $sc;
global $sourcedir;

$_SESSION['login_url'] = 'action=profile';


Note: do not add index.php? as it already stated by the script.

radj

ic..and wat if i want to an external page?

mertensberg

Quote from: radj on September 02, 2007, 08:10:44 AM
ic..and wat if i want to an external page?

er... haven't figured out yet... :(

radj


radj

hmmm..editing LogInOut.php does not seem to work for me..

King Dingeling

So, the fact stands - there's no way to redirect at login any more? I've gone through all faq's and threads once again, with no luck. Anyone want to prove me wrong? Please..

radj

actually,it works.. editing LogInOut.php.. it does now.. I don't know what I did..

Bulakbol

Quote from: radj on September 10, 2007, 07:55:11 PM
actually,it works.. editing LogInOut.php.. it does now.. I don't know what I did..

lol, maybe you can post your Loginout.php and we'll figure it out how you did it.  :)
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

radj

I just followed reply #4. That's the only change i made in the file.

King Dingeling

cool, thx very much, it's working great :D

DarkHarlequin

Hmm can someone post their code they got to work when not redirecting to an action page?  I basically have my login on my main page (not forum) and when the user logs in I want that page to just refresh itself with the user logged in instead of going to forums.

DarkHarlequin

Noone knows how to redirect after login to a non smf page? (basically my main home page, not forums)

radj

use this
$_SESSION['old_url'] = 'ur.url.com';
it will force all logins to go to the URL after this is set, even if logging in via forums.

hope it helps.

radj

wait.. here's another way.. this will force user to go to the URL after SUCCESSFUL login whether logging in from forums or from other pages

look for this code in LogInOut.php:

// Beyond this point you are assumed to be a guest trying to login.
if (!$user_info['is_guest'])
redirectexit();


add your URL as parameter of redirectexit..

// Beyond this point you are assumed to be a guest trying to login.
if (!$user_info['is_guest'])
redirectexit('the.url.com');


Advertisement: