ssi_login redirect

Started by Mr. Jinx, October 27, 2009, 02:55:47 PM

Previous topic - Next topic

Mr. Jinx

I'm using the php function "ssi_login" on one of my pages in joomla.
This seems to work, however the URL redirect feature just won'tt work!

For example, I include this code in joomla:

require_once("/path/SSI.php");
ssi_login('http://redirectpage');


This will add the default SMF loginbox, but after login you are always redirected to the forum and not the redirect url.

Somehow it must loose the variable '$_SESSION['login_url']. This is where the redirection url is stored, but once you are logged in, it must be gone or something.

Any other ways to solve this?

Arantor

What version are you using?

And is the require_once() the first line of the executed code (i.e. prior to any output)?

Mr. Jinx

I'm using SMF version 2.0 RC1.2.
The require_once is not executed first. If I put this as first, then the ssi_login function that's inside a joomla module, doesn't work. So I've put the require_once inside the module to get ssi_login to work (but this is without redirection).
You think there might be te problem?

Arantor

Is there anything being output prior to that require? If so that is likely the cause, since it interferes with SMF's cookies including the redirect.

That said, there is a bug in RC1.2 (and possibly RC1 itself) where the redirection gets dropped. The only way I found around it was to not use ssi_login itself, but to manually set $_SESSION['login_url'] and build the form myself. While that means using the same <form> entries you have much more flexibility for styling it as you wish.

Mr. Jinx

Quote from: Arantor on October 28, 2009, 03:12:38 PM
That said, there is a bug in RC1.2 (and possibly RC1 itself) where the redirection gets dropped. The only way I found around it was to not use ssi_login itself, but to manually set $_SESSION['login_url'] and build the form myself. While that means using the same <form> entries you have much more flexibility for styling it as you wish.
I've tried that, putting the <form> part into a module, but that didn't work.
I also tried hardcoding a redirect in SSI.php, also didn't work.
The only thing that works is from a normal .php file outside Joomla or from ssi_examples.php.
What also works is putting "$_SESSION['login_url'] = 'http://redirect'" in Boardindex.template.php, but that's not the way it should work.

Arantor

Since everything works except for the Joomla part, I can't help but assume that something in the Joomla process is interfering.

Mr. Jinx

You are right. It has something to do with joomla taking over another session, while SMF is using it's own session.
I've found a quick and dirty workaround for my situation which works perfect.
In case someone else has the same problem...
In Sources\LogInOut.php I added the following code:

Find:function Login2()
{
        global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
        global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;


Add after:if ( $_SERVER['HTTP_REFERER'] == 'http://www.domain.com/source) $_SESSION['login_url'] = 'http://www.domain.com/source';

This will redirect logins coming from a specific URL to the same URL after login without dealing with the joomla/smf session problem.

Arantor

Sounds like a plan, though as you say it is quick and dirty.

Advertisement: