Advertisement:

Author Topic: HowTo redirect the login or logout url with ssi_login resp. ssi_logout  (Read 112668 times)

Offline andrea

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,324
  • Gender: Female
  • I'm a smiley.
    • Smiley Sets
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



Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #1 on: October 12, 2004, 05:25:11 PM »
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]

Offline HoTmetal

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,950
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #2 on: October 29, 2004, 08:16:17 PM »
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #3 on: October 29, 2004, 09:57:55 PM »
$_SESSION['login_url'] = 'http://www.example.com/';
ssi_menubar();

-[Unknown]

Offline Kender

  • Jr. Member
  • **
  • Posts: 294
  • Gender: Male
  • I am Kender
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #4 on: November 05, 2004, 08:41:35 PM »
for those who want a login on every page (templated) and want to return to that page after

Code: [Select]
<?php
$current_url $_SERVER[&#39;PHP_SELF&#39;]; 
ssi_login($current_url); 
?>


<?php
$current_url $_SERVER[&#39;PHP_SELF&#39;]; 
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

Offline HoTmetal

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,950
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #5 on: December 09, 2004, 04:46:50 PM »
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. 

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #6 on: December 09, 2004, 08:02:29 PM »
Currently, I'm afraid there is not :/.

-[Unknown]

Offline nosleep

  • Semi-Newbie
  • *
  • Posts: 56
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #7 on: December 12, 2004, 01:01:23 PM »
Into which file exactly must I place this code:

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

sorry, but I am new to this.
« Last Edit: December 12, 2004, 01:06:20 PM by nosleep »

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #8 on: December 13, 2004, 12:13:48 AM »
Into the file you wish to show a link to logout from.  What are you trying to show?

-[Unknown]

Offline nosleep

  • Semi-Newbie
  • *
  • Posts: 56
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #9 on: December 13, 2004, 12:20:50 AM »
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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #10 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:
Code: [Select]
// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
setLoginCookie(-3600, 0);

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

Offline nosleep

  • Semi-Newbie
  • *
  • Posts: 56
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #11 on: December 13, 2004, 04:15:23 AM »
thanks millions, this is what I needed - works fine :)

Offline Foden

  • Semi-Newbie
  • *
  • Posts: 27
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #12 on: January 08, 2005, 08:09:37 PM »
Is there a way you can configure in LogInOut.php the url for both logging and out to return to the referring URL?

Code: [Select]
$ref = getenv('HTTP_REFERER');
That is what you would use to get the reffering url - would that help in any way?

Offline andrea

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,324
  • Gender: Female
  • I'm a smiley.
    • Smiley Sets
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #13 on: January 09, 2005, 12:12:06 AM »
Is described in reply #4 of this thread.
Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

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



Offline Foden

  • Semi-Newbie
  • *
  • Posts: 27
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #14 on: January 09, 2005, 01:41:33 AM »
Yes I saw that thread, but I was meaning for a global way, like in case you were actually browsing a forum as well.

Offline jgoodsell

  • Newbie
  • *
  • Posts: 1
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #15 on: March 09, 2005, 02:28:05 PM »
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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #16 on: March 11, 2005, 07:22:06 PM »
Code: [Select]
<?php

require_once(&#39;/path/to/SSI.php&#39;);

is_not_guest(&#39;Members only content!&#39;);

?>


The stuff only members can see.

Or:

Code: [Select]
<?php

require_once(&#39;/path/to/SSI.php&#39;);

if ($user_info[&#39;is_guest&#39;])
{
?>


Stuff for guests!

<?php
}
else
{
?>


The stuff only members can see.

<?php
}
?>

-[Unknown]

Offline NukeWorker.com

  • Full Member
  • ***
  • Posts: 416
  • Gender: Male
  • I love NukeWorker.com
    • Nuclear Jobs Pictures News
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #17 on: March 15, 2005, 11:01:43 AM »
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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #18 on: March 16, 2005, 12:00:20 AM »
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]

Offline NukeWorker.com

  • Full Member
  • ***
  • Posts: 416
  • Gender: Male
  • I love NukeWorker.com
    • Nuclear Jobs Pictures News
Re: HowTo redirect the login or logout url with ssi_login resp. ssi_logout
« Reply #19 on: March 16, 2005, 12:47:24 PM »
Shouldn't includding the ssi.php handle that?  If not, how do I get a session and session id?