OK. I did lots of searching, but can't find anything helpful about MY issue. OK, problem...
Anyway, what I want to do is take the value of the result set field "Key" and place it into a session variable for use elsewhere in the app. In "login.php" a successful login fires the line "$SESSION["key"] = $row['Key'];", then goes to another page. On that second page, "test.php," I want to display the value to make sure I captured it accurately. Right now it ("$SESSION["key"]") is blank, and I don't know why. Everything I've read so far tells me I'm doing this right, but it still doesn't work. Here's what I hope is enough "snippetting" to outline what I'm doing:
login.php:
<?php
session_start();
$sql="SELECT * FROM $table WHERE $UserFieldName='$username' AND $PasswordFieldName='$password'";
$result=mysql_query($sql);
$result = mysql_num_rows($result);
if($result!="0")
{ // If it does exsist
$SESSION["password"] = $password;
$SESSION["username"] = $username;
$SESSION["loggedin"] = true;
$SESSION["key"] = $row['Key'];
?>
<script type="text/javascript">
window.location = "test.php"
</script>
<?php
}
?>
test.php:
<?php
session_start();
if ($SESSION["loggedin"] != true)
{
?>
<script type="text/javascript">
window.location = "login.php"
</script>
<?php
}
else
{
echo "key = " . $SESSION["key"];
}
?>
Everything works fine, except the line "echo "key = " . $_SESSION["key"];." It shows "key ="
What am I overlooking?