简体   繁体   中英

Session not working on wamp but works on live server

I have this code and I have tried everything i can think of to get it to work on my WAMP local server any help would be greatly appreciated. I am PHP stupid. This works on a live server but not my WAMP server. I do get logged in just the pages do not seem to be passing the session variable to the proper user level. That's what's not working sorry for the poor description the first time.

if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['login']))
 {
if ($level == "Administrator") {

echo 'My Content';
}

elseif ($level == "Bank Officer") {
echo "";
}

elseif ($level == "Agent") {
echo "";
 }

elseif(!empty($_POST['login']) && !empty($_POST['password']))
{
$login = mysql_real_escape_string($_POST['login']);
$password = $_POST['password'];


$checklevel = mysql_query("SELECT * FROM users WHERE login = '".$login."' AND password = '".$password."' ");
if(mysql_num_rows($checklevel) == 1)
{
    $row = mysql_fetch_array($checklevel);
    $level = $row['level'];
    $_SESSION['level'] = $level;
}

$checklogin = mysql_query("SELECT * FROM users WHERE login = '".$login."' AND password = '".$password."' AND level='".$level."'");
if(mysql_num_rows($checklogin) == 1)
{
    $row = mysql_fetch_array($checklogin);
    $firstname = $row['firstname'];
    $login = $row['login'];
    $agent = $row['agent'];
    $_SESSION['agent'] = $agent;
    $_SESSION['firstname'] = $firstname;
    $_SESSION['login'] = $login;
    $_SESSION['LoggedIn'] = 1;

Thanks you for any help at all.

if ($_SESSION['level'] == "Bank Officer") 
{
    header('Location: index3.php'); 
    exit;
}
elseif ($_SESSION['level'] == "Agent")
{
    header('Location: index4.php'); 
    exit;
}
elseif ($_SESSION['level'] == "Bank Manager") 
{
    header('Location: index5.php'); 
    exit;
}
else
{
    echo "Contact Administrator";
    exit;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM