savagenoob Posted November 14, 2010 Share Posted November 14, 2010 I have a login script that sets all my $_SESSION[] variables, it was working, now I'm redesigning, and now its not working. I can echo the variables on this page, but when it redirects to dashboard.php and I do a session_start(), nothing. It's driving me nuts. <?php require_once ('../includes/config.php'); require_once ('../includes/connect.php'); function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $login = clean($_POST['login']); $password = clean($_POST['password']); //Input Validations if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: ../../index.html"); exit(); } //Create query $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['MEMBERID'] = $member['member_id']; $_SESSION['AGENTNAME'] = $member['firstname'] . " " . $member['lastname']; $_SESSION['OFFICE'] = $member['office']; $_SESSION['AGENCY'] = $member['agency']; $_SESSION['LOGIN'] = $member['login']; $_SESSION['EMAIL'] = $member['email']; $_SESSION['USERLEVEL'] = $member['level']; $_SESSION['EMPID']= $member['empid']; $_SESSION['LICENSE'] = $member['license']; session_write_close(); header("location: ../dashboard.php"); exit(); }else { //Login failed header("location: ../../index.html"); exit(); } }else { die("Query failed"); } ?> Link to comment https://forums.phpfreaks.com/topic/218602-session_start-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 14, 2010 Share Posted November 14, 2010 I don't see a session_start() anywhere in the posted code, so it will be a little hard for $_SESSION variables to actually be session variables. Without a functioning session_start(), you can set variables named $_SESSION and echo them on the page because they are just regular array variables. Link to comment https://forums.phpfreaks.com/topic/218602-session_start-help/#findComment-1133939 Share on other sites More sharing options...
savagenoob Posted November 14, 2010 Author Share Posted November 14, 2010 OMG, I must have deleted it at some point between the transfer of code. Something easy and dumb every time Thanks bro. Link to comment https://forums.phpfreaks.com/topic/218602-session_start-help/#findComment-1133943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.