so i'm trying to develop a login authorization script, this is my first attempt at any real session management.
anyway, i'm check to see if the session "user" has any value to it. if not, it calls a login function, pulls from database, ideally creates the user session and reloads the page. problem is, the session doesn't seem to carry over on the reload.
any suggestions?
code:
<?
session_start();
session_register("user","accessLvl");
function login($submit,$login,$password) {
if (!$submit) {
echo "<form name=\"login\" method=\"post\" action=\"\">"
."login <input type=\"text\" name=\"login\"> "
."password <input type=\"password\" name=\"password\"> "
."<input type=\"submit\" name=\"submit\" value=\"login\">"
."</form>";
} else {
include("ez_sql.php");
$login = $db->get_row("SELECT userName,userPwd FROM users WHERE userName = '$login' && userPwd = '$password'");
if ($login) {
session_register("user");
$user = $login->userName;
header("Location: ".$_SERVER["SCRIPT_NAME"]);
}else{
header("Location: ".$_SERVER["SCRIPT_NAME"]);
}
}
}
if (!$user) {
login($submit,$login,$password);
}else{
echo "user: $user";
}
?>