Image

Session Trouble

Hi everyone, I'm new here. I've been developing in PHP for about 2.5 years now, and consider myself fairly proficient with it. I'm currently developing a website, and I ran into some trouble with session control. I hope you can help me out.


What's happening is that I am registering a session variable within a class which happens to be in a different file than where I'm acessing the registered variable. Which shouldn't cause problems, but it is for me. In the file that I access the var in, I check to see if it's registered(session_is_registered("username")), it satisfies the if statement, thus it isset. So, when I try and print out $username, nothing happens. It essentially dosent exist. I tried $_SESSION["username"], nothing; making global $HTTP_SESSION_VARS["username"], nothing.
Here's some of the code:
session_start();
global $HTTP_SESSION_VARS;

if( session_is_registered("username") )

echo "username is registered
";
echo "name: ".$HTTP_SESSION_VARS["username"]."
";
echo "name: ".$_SESSION["username"]."
";
echo "name: ".$username."
";


echo "not logged in properly";


//------
function Login( $user )

global $config;

if ($user[username] && $user[pass])//make sure a username and password exist.. if they do, attempt to login

$result = mysql_query("SELECT * FROM photo_users WHERE username = '$user[username]' AND password = '$user[pass]' ");

if ( mysql_num_rows($result) == 1 )


session_register("username");
$username = $user[username];

header("Location: $config[scripturl]/photo.manager.php");


if( isset( $user[username] ) )

$out[body].="Error: Wrong User Name and/or password.";




$out[body].="Incorrect login.";


include("$config[html]");

//----------------------
What I think could be the issue is that once I register the variable, I redirect the user to a manager.php file via the header function. I'm not entirely sure if that should cause the client to lose the session information, though. Especially because it still passes through the if-statement as true.

Well, If you could help me out, that would be wonderful.
Thanks,
John