I've spent a few hours trying to resolve a problem with session variables. The session variables are intended to ensure login and/or whether or not a user is an administrator with other permissions. My intent is to test for the variables, if not present, redirect to login page or deny access.
It seems that once a session is started and variables set, I can access the variables on the page on which they are set, but on subsequent pages via link or Header redirect the session variables are not set and cannot be accesses. I read that Header redirect dumps session variables, so I tried simply painting a message that said "Login successful. Proceed" with a link on proceed. After clicking the link and going to page 2, session variables are not set. I've read site helps, my books, and am at a loss. Code follows. Any comments are GREATLY appreciated. Jim Gates [EMAIL PROTECTED] www.gatesinteractive.com PAGE 1 <? if(!session_id()){ session_start(); } if(!isset($_SESSION[sUi])){ session_register("sUi"); } if(!isset($_SESSION[sAdmin])){ session_register("sAdmin"); } require("php_includes/incl_sqlConnect.php"); $query = "SELECT * FROM tblUser WHERE username = '$username' AND password = '$password'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); if($num_results < 1) { Header ("Location:dsp_login.php?errMsg=i"); } else { $rows = mysql_num_rows($result); for ($i=0; $i<$rows; $i++){ $getUser = mysql_fetch_object($result); $_SESSION["sUi"] = $getUser->userID; $_SESSION["sAdmin"] = $getUser->admin; } Header ("Location:dsp_memberMain.php"); also tried echo "Login successful. <a href=dsp_memberMain.php>Proceed</a>"; } ?> PAGE 2 <? if (isset($_SESSION[sUi]) && $_SESSION[sAdmin] == 1){ echo "$_SESSION[sUi] and $_SESSION[sAdmin]"; echo "<br><a href=dsp_showUsers.php>Show users.</a>"; } else { echo "V no - developer test."; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php