Session Variables Not Being Passed
| From: | Jami | Date: | Sun, 01 Dec 2002 08:52:35 +0000 |
| Subject: | Session Variables Not Being Passed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-126589@lists.php.net to get a copy of this message | ||
The code that I have is as such:
//header.php
if(isset($_POST['login'])){
$checkuser = mysql_query("SELECT * FROM mainacct WHERE username =
'{$_POST['username']}' AND password = '{$_POST['password']}'
", $connection) or die ("Couldn't find user.");
if (mysql_num_rows($checkuser) > 0){
while ($row = mysql_fetch_array($checkuser)){
$_SESSION['UN'] = $row['username'];
$_SESSION['UserLoggedIn'] = True;
}
} else {
header("Location:login.php");
exit;
}
}
This file is then used as an include in main.php. As long as the variables are used ONLY in the
header.php file, it works. But when I try to call the session variables in main.php, it doesn't
show the values of UN or UserLoggedIn. session_start() is called in main.php. Is this a quirk with
sessions, or is there something more I am supposed to be doing? Running Apache 2 w/PHP 4.2.3 on
WindowsXP.
Jami