Redirect problem, using Login/Logout in SSI.php

Started by lchance, March 06, 2005, 03:44:42 PM

Previous topic - Next topic

lchance

Hello,

I am currently using SMF 1.0.2.  I am trying to incorporate the forum's membership base with my main website.  I have searched these forums for a solution and read over some of the posts.  Here is my problem(s):

When using this code,


include_once("forums/SSI.php");

if ( $context['user']['is_guest'] )
          {
               ssi_login( 'http://www.mywebsite.com/' );
          }
     else
          {
               ssi_welcome();echo "<br/>";
               ssi_logout( 'http://www.mywebsite.com/' );
          }


Using IE, the login boxes are displayed fine, however, after a successful login, I am sent to the forums, not the page I want to redirect to.  :(

When I go back to this page and click on the logout link, I am again sent to the forums with the following error: "Unable to verify referring url. Please go back and try again."

I would appreciate any help I can get.  I am about to pull my hair out.  ::)

Respectfully,
John


[Unknown]

Is the forum on a different subdomain from the website?

-[Unknown]

lchance


[Unknown]

You'll need to set your session.cookie_domain to ".tbhorsepedigree.com"... one way is to add this to Settings.php *before* the ?>:

ini_set('session.cookie_domain', '.tbhorsepedigree.com');

-[Unknown]

lchance

Quote from: [Unknown] on March 06, 2005, 09:38:39 PM
You'll need to set your session.cookie_domain to ".tbhorsepedigree.com"... one way is to add this to Settings.php *before* the ?>:

ini_set('session.cookie_domain', '.tbhorsepedigree.com');

-[Unknown]

Ok, I did what you suggested above.  It made no difference.  I copy/pasted exactly what you entered above, before the ?>.  Could I have entered wrong?  Is there something else I should be doing?

[Unknown]

Quote from: lchance on March 06, 2005, 09:48:08 PM
Ok, I did wha you suggested above.  It made no difference.  I copy/pasted exactly what you entered above, before the ?>.  Could I have entered wrong?  Is there something else I should be ding?

You'll need to most likely close all browser windows, and possibly restart your computer, before it makes a difference.

-[Unknown]

lchance

I tried everything you suggested, to no avail.  I reinstalled the forums to a directory under the site's and all worked as it should.  Thank goodness this was a new board.  Nothing important was lost.  8)

Thanks for your help [Unknown].

lchance

Quote from: lchance on March 06, 2005, 10:11:20 PM
I tried everything you suggested, to no avail.  I reinstalled the forums to a directory under the site's and all worked as it should.  Thank goodness this was a new board.  Nothing important was lost.  8)

Now, I can't even logout of the forums.   ??? :-\

[Unknown]

Please try clearing your cookies... you have a login cookie set for one path, and SMF isn't unsetting it because of this.

-[Unknown]

lchance

Quote from: [Unknown] on March 06, 2005, 11:37:32 PM
Please try clearing your cookies... you have a login cookie set for one path, and SMF isn't unsetting it because of this.

-[Unknown]
Yes, that fixed that but now I am right back where I was at when I first posted. 

When I login, I am directed to the forums.  When I logout, I am directed to the forums.  Strange part is, when I used the SSI.php code alone, it works fine.  When I incorporate the same exact code into my header.php, it doesn't.

Only thing I can think of is I have the SSI.php code inside a table but that shouldn't matter, should it?

[Unknown]

For SSI.php to work properly, you must use it like this:

<?php
include_once('SSI.php');
?>


Hi!!

<?php ssi_login(); ?>

Bye!


In other words, the first lines of your file MUST include SSI.php before anything else.

-[Unknown]

lchance

#12
You mean the actual include must be the first line, right?  The actual call to SSI.php can be anywhere, correct?

What I am attempting to do is have the SSI.php code in a file called header.php, then header.php is included in just about every page on the site.

[Unknown]

As long as header is the first thing any other file loads, it should be fine.

-[Unknown]

lchance

The first line in my header.php is:


<?php include_once("SMF/SSI.php"); ?>


The first line in my test page is:


<?php include("header.php"); ?>


And it doesn't work.  That is to say, the login/logout process works as it should, I just keep getting referred back to the forums, instead of my test page.  Sorry.

lchance

Can I get assistance one more time, please?  Here is what I have done and what I have learned.  I removed all the code from my header.php file, with the exception of:


<?php 
include_once("SMF/SSI.php");
     if $context['user']['is_guest'] )
          {
               $current_url $_SERVER['PHP_SELF']; 
       ssi_login($current_url); 
          }
     else
          
{
               $current_url $_SERVER['PHP_SELF']; 
       ssi_logout($current_url); 
          }
?>



After I made sure both the login and logout processes, as well as the referrals all worked as they should, I started adding pieces of the code back in until I broke it.

Here is the piece of code that broke everything and it doesn't make any sense to me:


$TotalHorses = "0";
     $dbh=mysql_connect ("localhost", "user_name", "passwd") or die ('I cannot connect to the database because: ' . mysql_error());
     mysql_select_db ("db_name");
     $result = mysql_query("SELECT name FROM horse");
     if( !$result ) { echo mysql_error(); }     
     while ($rows = mysql_fetch_row($result)) {
          $TotalHorses = $TotalHorses + 1;
     }
     mysql_close();


After adding the above code back into the header.php file, the referrals stopped working and something different.  This time I am getting an error at the bottom of my web page:

Database Error: Table 'TableName_Removed' doesn't exist
File: /home/tbhorse/public_html/SMF/Sources/Load.php
Line: 1193
Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

I never saw this error until after the fresh re-install of the forums.  This time I used MySQL for the sessions.  I allowed Fantastico to make the first installation, so I doubt it was setup this way before.

Please keep in mind, although I could probably stop using MySQL for the sessions and that would stop the error being displayed at the bottom of my web page, it would not correct the problem I am having with the referrals and SSI.php.

What are your thoughts on all of this?  I certainly appreciate any help I can get.

Respectfully,
John

P.S.  Hat's off to Fantastico.  Had it not been for it, I would have probably never heard of this forum.  I am glad I found it!  8)

lchance

Please, don't give up on me now [Unknown].   ;D

lchance

One tiny update.  I have a problem on every page that has MySQL code.  Please help.

lchance

Alright, I think I am going to lose my mind.   :-\

I went into the Admin area this morning and turned off the "Use database driven sessions" and now everything seems to work as it should, even with my MySQL code in.  What is going on?  Is it me or is there a bug?

It's probably me.   :P

Leipe Po

yeah that is a strange thing of php for example if you use in you header:

<?php
echo $text ;
?>

and somewhere else below the header it cant fill $text in
<?php
$text = Hello world ;
?>

so allways be sure if you do something like that its like the following


// the text thingy
<?php 
$text 
hello world;
?>

//end of text thinge begin of html
<html>
<head>
<title>hello world<t/itle>
</head>
<body>

<?php
echo $text ;
?>


</body>
</html>


that would work like a charm and this could easy be modified for your ssi problem...
   
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

lchance

Hello Leipe_Po,

Firstly, now that I have turned off the line telling SMF to let MySQL handle the sessions, I "hope" there is no more SSI problem.  I am about to go test a few more things.

Secondly, perhaps I am blind, but I fail to see how your example has anything to do with the problem I was having.  If you tell PHP to echo the value of a variable, in the case of your example, $text, and that variable is empty, then nothing gets printed to the screen.   Doing so should not cause an error.  So, you've lost me.

[Unknown] or any other developer,

Can someone please explain to me what happened?  Why, when having MySQL handle the sessions, were there problems?  Thanks.

Leipe Po

what i was trying to say is that the ssi.php must be parsed BEFORE anything else and i thought i give you an example...
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

[Unknown]

Please try:


$TotalHorses = "0";
     $dbh=mysql_connect ("localhost", "user_name", "passwd", true) or die ('I cannot connect to the database because: ' . mysql_error());
     $result = mysql_query("SELECT name FROM db_name.horse");
     if( !$result ) { echo mysql_error(); }     
     while ($rows = mysql_fetch_row($result)) {
          $TotalHorses = $TotalHorses + 1;
     }


Sorry for not responding, I lost the topic.

You may wish to also try disabling "database driven" sessions.

-[Unknown]

Advertisement: