<?
session_start();
header("Cache-control: private"); //IE 6 Fix
...
...
...
...
//IF FINDS ONE MATCHING PASSWORD AND USERNAME
if (mysql_num_rows($result) == 1)
{
$row = mysql_fetch_array($result);
list(,$lastname) = each ($row);
$_SESSION['authenticated'] = 1;
$_SESSION['username'] = $username;
header("Location: [url]http://localhost/default.php[/url]");
exit;
}
for some reason... this forum manipulates my code when i use the php text coloring feature... so here is the exact same code without the php text coloring feature.
<?
session_start();
header("Cache-control: private"); //IE 6 Fix
...
...
...
...
//IF FINDS ONE MATCHING PASSWORD AND USERNAME
if (mysql_num_rows($result) == 1)
{
$row = mysql_fetch_array($result);
list(,$lastname) = each ($row);
$_SESSION['authenticated'] = 1;
$_SESSION['username'] = $username;
header("Location: [url]http://localhost/default.php[/url]");
exit;
}
from here... the page is supposed to pass $SESSION['username'] and $SESSION['authenticated'] to the next page... default.php. i tested the values of username and session up to this point and it shows correctly.
but...when the next page loads...whose code looks like this...
<?
//STARTING SESSION
session_start();
header("Cache-control: private"); //IE 6 Fix
echo $_SESSION['username'];
//TESTING TO SEE IF USER IS ALREADY LOGGED IN
if (!isset($_SESSION['authenticated']))
{
$_SESSION['username'] = 'guest';
$_SESSION['authenticated'] = 2;
$username = $_SESSION['username'];
$authenticated = $_SESSION['authenticated'];
echo "You are logged in as <strong>$username</strong><br/><br/>";
}
//IF USER IS NOT LOGGED IN YET...SET USERNAME TO 'GUEST' AND AUTHENTICATION VARIABLE TO '0'
else
{
$username = $_SESSION['username'];
$authenticated = $_SESSION['authenticated'];
echo "You are logged in as <strong>$username</strong><br/><br/>";
}
?>
...when i check the value of $_SESSION['username'] isnt correct... nor is authenticated. is this an effect of 'header" ??? your values stored in session doesnt pass?
please help me out...
thank you
ron