Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHPSESSID lost? header() redirect error...

Status
Not open for further replies.

jay123454

Programmer
Jun 15, 2001
46
US
Hey,

I've got a php program that someone is trying to install on their server and there's a problem we weren't above to resolve with a couple hours of troubleshooting last night...was hoping you guys might have some ideas. It seems to me like it has something to do with PHPSESSID and/or header() redirect. The problem occurs when he submits the login page. It goes to the proper place in the code on the action from the login form but as you will see below it throws and error on the header() redirect. If he refreshes his screen though he is in fine?!?! But on every login there's an error...Here's more info below!

He's running as localhost

"I have a fresh install of debian linux (stable)
2.6 kernel

apache installed
mysql installed
php installed (4.3.10)"


This is the error message that's been stumping us.

"The connection was refused when attempting to contact localhost."

We spent a couple hours trouble troubleshooting and we narrowed it down to these few lines...which was exactly the same few lines that gave me problems above. This is on login, he submits the login and then this happens.

Here's the normal code below...I believe the problem is occuring right above the header() redirect in the if block to my_team.php



if(!($rs->EOF))
{

$users_ID=$rs->fields("ID");
$leagues_ID=$rs->fields("leagues_ID");
session_start();
session_register('USERSID');
//$USERSID=$users_ID;
$_SESSION['USERSID']=$users_ID;
setcookie("LEAGUEID",$leagues_ID);

if(strlen($leagues_ID)>0)
{
session_write_close();
header("Location: {$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID");
exit();
}
else
{
session_write_close();
header("Location: {$PHPFFL_WEB_ROOT}leagues.php?PHPSESSID=$PHPSESSID");
exit();
}

}



Modified to:

session_write_close();
die("here");
header("Location: {$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID");
exit();


It outputs "here" to the screen.


Modified to:

session_write_close();
header("Location: {$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID");
die("here");
exit();


It outputs "The connection was refused when attempting to contact localhost."


Modified to:


Modified to:
session_write_close();
echo "{$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID";
header("Location: {$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID");
die("here");
exit();


It outputs "The connection was refused when attempting to contact localhost."


So it looks to me like the session data is not in $PHPSESSID and maybe that's what's causing the problem?

You guys have any ideas?

Also, if he refreshes his screen he is logged in and the program functions normally. Also, the action on the form that passes the login data is

action='$PHP_SELF'

Thanks!
jason
 
ok.. just a question.

the following section

echo "{$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID";
header("Location: {$PHPFFL_WEB_ROOT}my_team.php?PHPSESSID=$PHPSESSID");

i gather you are parsing this to generate the {$PHPFFL_WEB_ROOT} section now just before this you have the

session_write_close();

are you by chance closing the db or session connection somewhere during this function. if so that could be your problem.

Cheers

 
hey,

thanks for getting back to me. Actually, we figured out a solution to his problem.

$PHPFFL_WEB_ROOT is a variable stored in the config.php file. I was just echoing it there to verify where the header() was redirecting to. That wouldn't be in the program other than troubleshooting.

Anyways, here's what fixed it.

Changed
$PHPFFL_WEB_ROOT="to
$PHPFFL_WEB_ROOT="
And that seemed to work...even thought the was running this as localhost. Everything else worked with localhost except the header() redirect?!? Strange...works on my setup. Anyways, it's fixed now!!

Thanks for replying.
jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top