News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Gremlins in my ssi_login()... Please help me find them!

Started by SubCog, December 30, 2008, 09:40:48 AM

Previous topic - Next topic

SubCog

Ahh!!!  Those gremlins are tampering with my website again.

I know they're there, but I can't quite find them.  Can you help me?


So here's me using the ssi_login() and ssi_logoff() in my website:
ssi_welcome();
echo "<br />";

ssi_login();
ssi_logout();


Everything looks good:


But when I login, it takes me somewhere else:


That's no problem though, 'cause I havn't passed in a redirect argument yet.  Well, lets go ahead and do that.  Let's just copy the URL from

and paste it into the code:ssi_welcome();
echo "<br />";

ssi_login("http://silvastories.com/comic.php?page_id=1");
ssi_logout("http://silvastories.com/comic.php?page_id=1");


Hey, that's working great!  Now when I log in it takes me to the proper place:


Alright, but I don't want a static URL passed into the login and logoff functions, 'cause I don't want the user to always be redirected back to that same page.  I want the user to be redirected back to the page they were on before, so I need to dynamically build the URL.

The easiest way I can think of to do that is with the $_SERVER array.  I'll just use $_SERVER[REQUEST_URL]:ssi_welcome();
echo "<br />";

$redirect_path = $_SERVER[REQUEST_URL];
echo "<br />redirect_path : $redirect_path<br />";

ssi_login($redirect_path);
ssi_logout($redirect_path);


Notice that I echoed back the $redirect_path variable, to make sure I got the URL that I wanted.  Now lets see if $_SERVER[REQUEST_URL] actually gave me what I needed.



Okay, so I've got the URL, and I'm ready to pass it into the login and logoff functions.  This will work for sure, right?  Let's find out:


Oh no, there's that Gremlin I told you about!  For some reason, even though the correct URL looks like its being passed into the functions, I'm still being taken somewhere else entirely when I log in.


Okay, well maybe there's something weird happening because I'm using the $_SERVER array.  Lets try something more simple.  I always want the return the user to the same script when they log in or out, just on different pages.  Maybe I can try using a static URL, and just put in the page_id at the very end, like this:ssi_welcome();
echo "<br />";

$page_id=$_GET['page_id'];
echo "<br />page_id : $page_id<br />";

$redirect_path = "http://silvastories.com/comic.php?page_id=" . $page_id;
echo "<br />redirect_path : $redirect_path<br />";

ssi_login($redirect_path);
ssi_logout($redirect_path);


So I've gotten the page_id out of $_GET, and echoed it back to make sure I got it.  Then I build my URL from a static string, and I add the $page_id to the end.  I've echoed the $redirect_path back too, just to make sure it works.  Lets try it:


Okay, so both the $page_id and $redirect_path variables are working great.  Let's try logging in now:


Okay, that's really strange.  It redirected me to the URL I specified, minus the page_id that I put in!  That is a serious gremlin, and I don't know what's going wrong. 

Okay, lets try one more thing, just for comparison.  Maybe it has something to do with putting a variable into the $redirect_path string?  So lets try manually defining $page_id, instead of getting it from $_GET.

ssi_welcome();
echo "<br />";

$page_id=1;
echo "<br />page_id : $page_id<br />";

$redirect_path = "http://silvastories.com/comic.php?page_id=" . $page_id;
echo "<br />redirect_path : $redirect_path<br />";

ssi_login($redirect_path);
ssi_logout($redirect_path);


so it seems to work:

and when I log in, it works just fine:

so I can put variables into the $redirect_path variable, and the login and logoff functions accept them, unless they come from the $_GET or $_SERVER arrays.  Does that make any sense to you?




Please help me, or else the gremlins will win!



I'm using simple machines version 1.1.7, btw.  I've never had this problem with previous versions, so I believe it may be a bug in this version???  Although I still can't explain how its stripping parts off of my URL string.

Sel_888

I am having similar problems with my ssi_login.

Check out my thread - http://www.simplemachines.org/community/index.php?topic=283049.0

I tried to do what you did with actually putting the URL of where I want it to load
Quotessi_login("http://www.lagunachapala.com/index.php?page_id=1");
But it still insist on going to my forum page (a subdomain of that site)

Again, I have the 'include all subdomain cookies' turned on...

Let me know how you are doing... and maybe we might be able to work this out.
-Sel
I didn't get it wrong, I just found 10,000 ways it doesn't work...

LagunaChapala.com - A community site for South Shore residents

SubCog

okay, I got it fixed.  This is really bizarre though.  I was calling ssi.php from my header.php.  Index.php called header.php which called ssi.php.  Well, for some reason, as soon as I renamed header.php to something else, like header2.php, then it works properly.

Advertisement: