My session based login system worked perfectly until about last week when I looked at it for the first time in about 2 weeks,
and now it's not working. No code has been changed at all
My website hosts recently upgraded to PHP 4.3.3 their Linux servers.
Register Globals has now been turned off by them.
When I input my form data (username and password)
it is directed to login.php
<form name="login" method="post" action="login.php">
In login.php
<?php session_start();
global $_SESSION;
global $_POST;
?>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$my_session_username = $myrow[0];
session_register("myname");
echo $myname;
print '<meta http-equiv="refresh" content="0; URL=/main.php">';
The echo $myname does print out the username registered OK.
This redirects to the main page main.php
which verifies that the session id exists again.
Unfortunately, the session id $myname doesnt exist on the new page,
or is blank
<?php session_start();
global $_SESSION;
global $_POST;
?>
<?php
if (isset($_SESSION['myname'])) {
echo "Hello <b>{$_SESSION['myname']}</b>";
//(this prints "Hello" only)
} else {
echo "Hello <b>Guest</b><br />";
echo "Would you like to login?";
}
?>
<?php
echo "A";
echo $myname;
echo "B";
echo $_POST['myname'];
echo "C";
echo $_SESSION['myname'];
//(these 3 echo's print blank) - just outputting these for testing
Can anyone please shed some light on what might be happening, and why $myname
is correct in login.php but is blank in main.php
Thanks in advance,
Adrian.