Hi all. Okay, I'm logging in from an index page, passing the $_POST variables to a function that runs a query with the passed vars against a database, then should use the resulting recordset to set session variables. This works, as long as I echo the session vars from the page that calls the function. As soon as I move to another page, despite having called the session_start() function, I get one of two responses. Either the index is undefined or there's nothing there. This is despite the fact that there most certainly is something in each of the 3 set session variables on the previous page. It's just not transferring over. Anybody have any ideas? The verification code is as follows:
function logIn($usr, $pass){
require("../connections/cnxns.inc");
mysql_select_db($database);
$qry="SELECT empID, name, department FROM tblemp LEFT JOIN tbldept ON dept = deptID WHERE empID = '".$usr."' AND pass = '".$pass."';";
$rs=mysql_query($qry, $cnxn);
$line=mysql_fetch_assoc($rs);
$numRows=mysql_num_rows($rs);
if($numRows==1){
session_start();
session_register("name");
session_register("dept");
session_register("id");
$HTTP_SESSION_VARS['id'] = $line['empID'];
$HTTP_SESSION_VARS['name'] = $line['name'];
$HTTP_SESSION_VARS['dept'] = $line['department'];
echo $HTTP_SESSION_VARS['id']."<br>";
echo $HTTP_SESSION_VARS['name']."<br>";
echo $HTTP_SESSION_VARS['dept'];
// header("Location: ".$line['department']."Index.php");
} else {
header("Location: index.php");
}
}
I've commented out the header line in leiu of using a text link to move on to the next page - thought maybe, for some odd reason, that line was killing things. It's not the problem. The next page contains the session_start() call, and uses <?php print($HTTP_SESSION_VARS['name']); ?> to try to output the name. I get nothing. Literally. I've used sessions variables succesfully before on this server (no changes or updates - it's my personal testing system - so I know that there's no new settings I should have to deal with). It's just wierd.
Any ideas?
P.S. - the echo calls are there for testing. They work fine on the page that calls this function, but again I get nothing on the next page.