News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SSI - Redirection after Login

Started by Eris Siva, October 12, 2004, 05:38:29 AM

Previous topic - Next topic

Eris Siva

I found this when I was searching for the answer to this problem:
Quote
You can already use SSI to redirect back to your site or indeed anywhere you want after login.  This has been simplified for the next release.

-[Unknown]


How would I go about doing this?

A.M.A

Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Eris Siva


sodface

I get the following error after click that link (which I would like to read  ;) )

QuoteThe topic or board you are looking for appears to be either missing or off limits to you.

A.M.A

hope this will help:

set $_SESSION['login_url'] before you call the ssi_login() function

   // Off to the merry board index we go!
   if (empty($_SESSION['logout_url']))
      redirectexit('');
   else
   {
      $temp = $_SESSION['logout_url'];
      unset($_SESSION['logout_url']);

      redirectexit($temp, false);
   }
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

sodface

Thanks, I will continue to mess about with this, I am still in the very early stages of development and will attempt to comprehend the full use of ssi before I start asking random questions.  I basically want there to never be a login box in the forum itself, but rather a front page login and users should be redirected to this front page login after a logout in the forum also... (this isn't a question, just what I'm working on at the moment.)

Thanks again.

sodface

#6
This is what I came up with - am I taking the long way around?

Goal - No guest access to the forum, but also redirect away from the forum directory to an upper level main page.

So the server is laid out like:

www.mysmfsite.com/index.php (main site)
www.mysmfsite.com/forum/index.php (smf forum dir)

I wanted the upper level index.php (which will have it's own login box) to be loaded in the following situations:
  • A guest tries to bypass the front page by navigating directly to hxxp:www.mysmfsite.com/forum/index.php [nonactive]
  • After a guest logs in from the main page (not the forum) they get redirected back to the main page.
  • When a member logs out of the forum they get redirected to the upper level main page.

In other words, you won't be able to get into the forum directory unless you are logged in from the main page.

First, I created a new theme based off the default and unchecked "allow guests to browse the forum"

Second, in the new theme's index.template.php file I set the login and logout url's:
function template_init()
{
global $context, $settings, $options, $txt;
$_SESSION['login_url'] = 'http://www.mysmfsite.com/index.php';
$_SESSION['logout_url'] = 'http://www.mysmfsite.com/index.php';


Third, in the new theme I added the file Login.template.php and added the redirectexit call under template_kick_guest section:
function template_kick_guest()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

redirectexit('http://www.mysmfsite.com/index.php',false);


I also commented out the remainder of that section which displays a login box.

This seems to work like I wanted so far.  I haven't really started putting the main page together yet, but I threw in a ssi_login() function just for testing, again seems to work good.

I couldn't seem to get any version of the code A.M.A. posted to work like I wanted.

Kender

I am trying to do something a little different here, i would like to use the page that the script is loaded on, $_SERVER['PHP_SELF'] or similar to reload to after logging in, in other words, if they are on joe.php, then it returns them to that page after logging them in...

any help here? 
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Kender

javascript history command will work with logout (but wont refresh so that it still shows 'logout') but wont work with login

i would rather not use history command, basically because of the non refresh, and i dont want to refresh every page on load just because....

so any ideas?
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

andrea


Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

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



Kender

replied in there with my resolution, thanks for the lead
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Advertisement: