我在public static login()
和class Member
中使用此static $logged = false
方法作为默认值。
当登录数据通过要检查的方法时,$logged
应更改为true
并重定向到配置文件页面。
但是在profile.php $logged = false
上恢复默认值。
我错过了什么?
class Member
{
public static $logged = false;
public static function logIn($data)
{
global $db;
global $messages;
//$dataChecked = self::filterData($data);
$user = $db->fetch("select * from gym_members where email = :email",['email'=>$dataChecked['email']]);
if ($user&&$user->status>"0")
{
if ($data['pass'] == $user->password)
{
$_SESSION['id'] = $user->id;
self::$logged = true;
header("Location:profile.php");
}
else
{
header("Location:login.php");
$messages = 'incorrect password';
}
}
else
{
header("Location:login.php");
$messages = "User not found";
}
}