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

andrea

Login

The SSI function ssi_login();   shows the forum login box. The url to be loaded after the login is performed can be controlled by setting the variable $_SESSION['login_url'].

Here is a sample script:

Quote
<?php
include('/pathtoyour/SSI.php');

print "Here are some PHP commands. <br />";

$_SESSION['login_url'] = 'http://urltoyourindexpage';
ssi_login();

print "Here are some more PHP commands. <br />";

?>



Logout

The function ssi_logout();   shows the logout link. After the logout the user is redirected to the boardindex. By setting the variable $_SESSION['logout_url'] you can control the link where the user is sent to after the logout.

Here is a sample script:

Quote
<?php
include('/pathtoyour/SSI.php');

print "Here are some PHP commands. <br />";

$_SESSION['logout_url'] = 'http://urltoyourindexpage';
ssi_logout();

print "Here are some more PHP commands. <br />";

?>

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

In RC2, at least, these are equivalent:

$_SESSION['login_url'] = 'http://www.example.com/';
ssi_login();

And:
ssi_login('http://www.example.com/');

It's just a short cut.  The same goes for logout.  But, note - this won't work with older, modified SSI.php's.

-[Unknown]

HoTmetal

Ok that works great... Now where do I change it so that they hit my index page of my site when logging in/out while using the login/out buttons that I have called in using ssi_menubar(); ?? OR I gues sI could just remove the login/out button from within the themes temp. hmm...any better Ideas,,,, thanks again RickC

[Unknown]


Kender

for those who want a login on every page (templated) and want to return to that page after

<?php
$current_url $_SERVER['PHP_SELF']; 
ssi_login($current_url); 
?>


<?php
$current_url $_SERVER['PHP_SELF']; 
ssi_logout($current_url); 
?>


this will return you to where they logged in at, or out at
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

HoTmetal

Thanks Kender thats just what I was looking for. Now is there a way to add it so that the user goes to the /forum/index.php?action=login, then once they log in, it shoots them back to where they were before?

The reason I want to know is I stopped using the ssi for the login, now I have the nav bar ssi'ed onto every page. 

[Unknown]


nosleep

Into which file exactly must I place this code:

$_SESSION['logout_url'] = 'http://urltoyourindexpage';
ssi_logout();


sorry, but I am new to this.

[Unknown]

Into the file you wish to show a link to logout from.  What are you trying to show?

-[Unknown]

nosleep

I don't want to show anything. I simply want to make it so that when people Logout with the normal logout button (as on any template), they are redirected to another site.

That is the code I need. As I'm new to this I would be grateful if I could be told which code to insert to exactly where to achieve my task.

Thank you.

[Unknown]

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]

nosleep


Foden

Is there a way you can configure in LogInOut.php the url for both logging and out to return to the referring URL?

$ref = getenv('HTTP_REFERER');

That is what you would use to get the reffering url - would that help in any way?

andrea


Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Foden

Yes I saw that thread, but I was meaning for a global way, like in case you were actually browsing a forum as well.

jgoodsell

if I include login ssi on a page, how then to check if user is logged in?

also, is it possible to show login form only if user is not logged in, and show logout otherwise?

i basically want to have login for a site and if logged in, extra content is available. but i am unsure how to check if user is logged in, i don't see some SSI to do this.

[Unknown]

<?php

require_once('/path/to/SSI.php');

is_not_guest('Members only content!');

?>


The stuff only members can see.


Or:

<?php

require_once('/path/to/SSI.php');

if (
$user_info['is_guest'])
{
?>


Stuff for guests!

<?php
}
else
{
?>


The stuff only members can see.

<?php
}
?>


-[Unknown]

NukeWorker.com

On my home page, I have this code:

         <?php
         $current_url = $_SERVER['PHP_SELF'];
         ssi_login($current_url);
         ?>

         <?php
         $current_url = $_SERVER['PHP_SELF'];
         ssi_logout($current_url);
         ?>

When I login and imediatly logout, it works fine. 

If I login then exit the browser, then open a new browser and try to logout with that command, I get this error:

Session verification failed. Please try logging out and back in again, and then try again.

[Unknown]

You have to get a session and session id before you can log out.  You can't just copy the logout link and go directly there, because that session id is going to be invalid.

-[Unknown]

NukeWorker.com

Shouldn't includding the ssi.php handle that?  If not, how do I get a session and session id?

Advertisement: