HowTo redirect the login or logout url with ssi_login resp. ssi_logout

Started by andrea, October 12, 2004, 04:04:42 PM

Previous topic - Next topic

HoTmetal


[Unknown]

Then you shouldn't get any errors...?  I'm not sure why you would have any on those lines from my copy.

-[Unknown]

natem345

Quote from: [Unknown] on December 09, 2004, 08:02:29 PM
Currently, I'm afraid there is not :/.

-[Unknown]

Here's how I did it; seems to work for me. In LogInOut.php under:
   // Set the login URL - will be used when the login process is done.
   
I took out the if/else and just put:
$_SESSION['login_url']= getenv('HTTP_REFERER');


costanza

Ok, I hate that this was the solution... but of course the new version solved my problem.  I used the code from the first post in this thread and it works like a charm.  I'm referring to 1.1 beta 3 of course.  Thanks everyone for all the help though.

HoTmetal

Ok I've been sooooooooooooo busy. I haven't had time to post this latly. This is  from my LogInOut.php. I included the line numbers. I keep getting errors  on 98.
Quote
97         // Strike!  You're outta there!
98      if ($_GET['member'] != $ID_MEMBER)
99         fatal_lang_error('login_cookie_error', false);



Rudolf

The ssi_login and ssi_logout functions have a redirect_to parameter.

You can simply use ssi_login('www.yourdomain.com/your/site/page.php');
Similarly ssi_logout('www.yourdomain.com/your/site/page.php');

It's that simple. What's with that $_SESSION thing??!!  :-\

Rudolf

EDIT: now I see that this is an old thread, maybe already dead  :-[
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

HoTmetal

Quote from: rudiksz on September 05, 2005, 02:21:37 PM
The ssi_login and ssi_logout functions have a redirect_to parameter.

You can simply use ssi_login('www.yourdomain.com/your/site/page.php');
Similarly ssi_logout('www.yourdomain.com/your/site/page.php');

It's that simple. What's with that $_SESSION thing??!!  :-\

Rudolf

EDIT: now I see that this is an old thread, maybe already dead  :-[

Yeah, it was an old thread, but I brought it back to life.... My SSI login works, but I wanted my users to login & stay on the same page that they logged in on.....I set it up , but the way I did it, didn't work with the new ver. of SMF. & now I get an error on line 98

Rudolf

What errors are you getting? The code you shown doesn't says too much.
You have to declare the $ID_MEMBER to use it. I'm not even sure if that's available in the SSI.  :-\
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

HoTmetal

Quote from: rudiksz on September 05, 2005, 11:44:28 PM
What errors are you getting? The code you shown doesn't says too much.
You have to declare the $ID_MEMBER to use it. I'm not even sure if that's available in the SSI.  :-\
I used the code givin here. [
quote author=rickc link=topic=18077.msg273916#msg273916 date=1117597117]
Quote from: [Unknown] on December 13, 2004, 03:28:49 AM
So you mean, log out from the forum - not from your SSI driven site?

If so, in LogInOut.php, find:
// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);


After those lines, add:
$_SESSION['logout_url'] = 'http://www.google.com/';

-[Unknown]

Is this why all my users get an error on line 98 of the LogInOut.php??

Thanks in advance RIckC
[/quote]

But I've since upgraded to a newer ver of SMF. <SMF 1.0.5.> But I plan on upgrading to SMF 1.1 RC1 this weekend. Should this mod work with  SMF 1.1 RC1.? OR has the LogInOut.php chanced again? Thanks in adance rickC

zodiak

I also have the login-redirect problem. Here is the code used for calling the function:

include($path_forum_absolute.'SSI.php'); // the include works fine
ssi_login($path_livesite); //  $path_livesite = 'http://www.mydomain.com/'


But every time I finish at the forum home page.
As far as I managed to debug the problem I found out that at some point the $_SESSION['login_url'] is deleted. Probably before the redirect is called.

Any body found a solution?

P.S. I.m using SMF 1.0.5

zodiak

Ok I tried SMF 1.1 RC1.

With Database driven sessions login redirect doesn't work.
When I turned them off it worked.

Why?

P.S. Same thing on 1.0.5. I finaly tried it.

maddezi

Ok I have gone through eveything that was post here because i was looking for the easy way out. And the only thing that work  was the log_out
// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);
$_SESSION['logout_url'] = 'http://www.yoursite.com///';


But as i kept on trying no one could have really get the log_in to work. what I have done is erase under the // Set the login URL - will be used when the login process is done.:--
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']);

And placed
$_SESSION['login_url'] = 'http://www.yoursite.com///'; it works like a dime.

oxynom

OK after about 6 hours guessing and trying I finally figured it out this works.

The login and logout function are stored in the file 'loginout.php'. Why for some the logout function works is because, when you click on logout then you don't get through any step (page) before you get logged out. That means you click it and you are gone. One step and the $_SESSION['logout_url'] works.

So if you put:

$_SESSION['logout_url'] = 'http://www.yoursite.com/';

or

$_SESSION['logout_url'] = $_SERCER['PHP_SELF'];

both will work


THE LOGIN

The login won't work this way because it goes to a login screen. The best you can get with this is you land at the LOGIN SCREEN but with yourself already logged in! :-[

One way to solve this problem is to find the redirectexit() function. ( was to lazy to do that, and it's my first day using SMF) so i figured out a handy way.

I put this into the header of my Webpages [note: not the forum header (index.template.php)]

$current_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

and in the box where i have my login i put this:


<?php
include "ssi.php";

if (
$context['user']['is_logged'])
{
echo $txt['hello_member'], ' <b>'$context['user']['name'], '</b>';
echo '.<br /><a href="index.php?action=profile">Profile</a> | ';
ssi_logout($current_url);
}
else
{
ssi_login($current_url);
}
?>



The reason why I used "http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']" to locate my current url is because anyother type i used would end up unreconizeable for the SMF. The url would look something like this if I would have used $_SERVER['PHP_SELF']:

URL: http://myserver.com/forum/index.php?home.php [nofollow]

I called ssi_login from from my homepage(home.php).

Well this works for me now...and i hope i could help you guys out.

If you are a little interested in Travel then visit my Project.
SMF 1.1 RC2 bridged with Coppermine and heavily modded.
Destinedia - The Shrine of Travel [nofollow]

goofy2feet

The following code on my SSI-driven page does not work - on log-in I am always sent to the forum index, not the url in $current_url. On log-out I am re-directed to the forum index, generating 'An Error has occurred' page.


include '../lglbbs/SSI.php';
$current_url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$page="links"; // variable I use elsewhere in the page
...
...
if (!$context['user']['is_logged']) { // check if user is logged in or not
echo 'BBS Members - please log-in using your usual
username and password for full functionality.';
ssi_login($current_url);
} else if ($context['user']['is_logged']) {
ssi_logout($current_url);
}


Even with this code set, when I hover over the logout link - the status bar shows the target url as:
http://language-global.com/lglbbs/index.php?action=......
There is no 'www.' in the url - is this what is causing the error page on logout? In any case why is $current_url ignored by both ssi functions??

EDIT: Then I tried the same thing again but with database-driven sessions disabled : the result was that both ssi_login and ssi_logout function as expected.
Free Talk forums featuring DzinerStudios premium themes.

HoTmetal

Hmmm ... It seems to me I did something similar. If I recall, I added my own header into the  index template.php & used a similar code there. But since then, I've added Joomla CMS to my site & it has a feature like this built in. Good to see someone posted a work around here though, as I have forgoten about this thread :D

psychophat

goofy2feet try doing Reply #10 by [Unknown] it works. You can incorporate it to your logout without any errors but it redirects you to the forum index. Haven't heard from anyone if there is a workaround for this to end up back to anypage or the referring page from which you logged out from, still waiting.
I adore this forum, from zero PHP knowledge to +.1% per post
I'm going to get the charter member thinggy when I get to save some cash
SMF v.1.1RC2
PHP v.4.3.11

Gregory

YEAH!!! Got it working  :D

I had <? php and never noticed that space before the < before.

Also, people should note that if your page/site structure is built up using includes the inclusion of ssi needs to go before any of your files output html or spaces. (I gather this is because the SSI needs to login and then redirect back before the page outputs stuff)
Ant's Life - My morpg that is integrated with SMF for good communications between players and staff.

goofy2feet

Quote from: [Unknown] on December 13, 2004, 03:28:49 AM
So you mean, log out from the forum - not from your SSI driven site?

If so, in LogInOut.php, find:
// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);


After those lines, add:
$_SESSION['logout_url'] = 'http://www.google.com/';

-[Unknown]
This only seems to be about logging out; my main problem is with logging in.
Free Talk forums featuring DzinerStudios premium themes.

Captain_Morrigan

Ok, I've tried practically all of the suggestions here.

I really want my board to redirect to the current page when not on SMF. I have tried all suggestions but I don't want to put a static page to redirect to. So if I am on my News page I want it to redirect to my news page if I'm on my downloads page I would expect it to redirect to my downloads page. All suggestions here still redirect me to my forum.

Now could it be that my forum is on a subdomain instead of a subfolder?

I must admit the one:
$_SESSION['logout_url'] = 'http://www.google.com/';
Does work if I'm not using variables.

When I echo the results from the variables it shows the correct data but it is not showing the correct page on redirect.

I think what it is is when it logs the redirect it is losing the information in the LogInOut.php file because I am no longer on the main page I am in the subdomain.

Generally what I want is:
I'm here:
http://site.com/downloads.php
I login.
I'm here:
http://site.com/downloads.php

Or any other page that I'm on. Right now what I'm getting is:
I'm here:
http://site.com/downloads.php
I login.
I'm here:
http://subdomain.site.com/index.php

Also, the logout doesn't work either so I need to fix both.

If you can PM me the results but I will be checking back here regularily.

JayBachatero

You can use
$_SESSION['login_url'] = 'http://site.com' $_SERVER['PHP_SELF'];

If you have query string like index.php?news use
$_SESSION['login_url'] = 'http://site.com' $_SERVER['PHP_SELF'] . '?' $_SERVER['QUERY_STRING'];
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Advertisement: