Hello! I'm trying to figure out why my session variables keep hiding....
Background:
On my site, I have a login box, which allows you to login. This login box works as
expected. It authenticates the provided credentials against my database, and then sets
some pre-registered session variables to values pulled from the DB. What I am
experiencing, is that my session variables will be defined, and then lose their values
when the first link is followed. I've placed a reference to $PHPSESSID into the title
of the page, and note that the $PHPSESSID remains constant. Is there something in my
code that is causing this? Is there a way that I can rewrite my code to help avoid
this?
Here is my index.php, other relevent code to follow:
<?
include("include/user.conf");
if (!$theme) { $theme = "default"; };
include("include/core_functions.php");
if ($AuthAction) {
switch($AuthAction) {
case login:
include("include/db.conf");
$sql = "SELECT uid,username,password,first,last,acl FROM users WHERE
username='$username' AND password=PASSWORD('$password')";
$result = mysql_query($sql) or die ('Unable to execute SQL Query.');
$dberror=mysql_error();
$dbnum=mysql_errno();
if ($dberror) {
$AuthErr = $dberror;
} else {
$num = mysql_numrows($result);
if ($num !=0) {
$sess_uid = mysql_result($result,0,"uid");
$sess_acl = mysql_result($result,0,"acl");
$sess_fname = mysql_result($result,0,"first");
$sess_lname = mysql_result($result,0,"last");
$sess_uname = mysql_result($result,0,"username");
$sess_auth = "1";
} else {
$AuthErr = "<FONT SIZE=-1 COLOR=RED>Login Incorrect!</FONT>";
};
};
break;
case logout:
break;
}
};
if (!$action) { $action = tba; };
if (!$title) { $title = "$PHPSESSID"; };
if (!$headline) { $headline = "<H2>An E-Haven for Displaced Northpointers<H2>"; };
include("Themes/".$theme."/".$theme.".theme");
?>
Here is user.conf:
<?php
if (!$PHPSESSID) {
$sess_uid = "";
$sess_acl = "";
$sess_fname = "";
$sess_lname = "";
$sess_uname = "";
$sess_auth = "";
session_register('sess_uid');
session_register('sess_acl');
session_register('sess_fname');
session_register('sess_lname');
session_register('sess_uname');
session_register('sess_auth');
};
?>
Shouldn't this work? I reference the session variables within functions, but that
shouldn't effect anything. I always make sure to call global for each variable before
I use it.... any ideas?
Thanks in advance!
Jason Bell