登录PHP后如何获取用户ID会话?
最后一页是模型中的“database.php”:登录PHP后如何获取用户ID会话?,php,database,function,session,Php,Database,Function,Session,最后一页是模型中的“database.php”: case 'login':{ if(isset($_POST['login'])) { $username = $_POST['username']; $password = md5($_POST['password']); if($db->login($username, $password)){ $_S
case 'login':{
if(isset($_POST['login']))
{
$username = $_POST['username'];
$password = md5($_POST['password']);
if($db->login($username, $password)){
$_SESSION['user_name'] = $username;
//$_SESSION['user_id'] = $userID;
if($_SESSION['user_type'] == 1){
header('location: index.php?controller=admin&action=adminhomepage');
}else{
header('location: index.php?controller=view&action=homepage');
}
} else{
header('location: index.php?controller=user&action=login');
}
}
require_once('View/login.php');
break;
}
我不知道如何获得会话的用户ID以及用户类型登录成功后的网站。我只获得用户名的会话。救救我 我希望你不打算把这个放到网上;这是完全不安全的使用。是的,我只是有一个PHP的基本知识,我正在做最后的项目。我只是想知道如何获得用户ID会话
case 'login':{
if(isset($_POST['login']))
{
$username = $_POST['username'];
$password = md5($_POST['password']);
if($db->login($username, $password)){
$_SESSION['user_name'] = $username;
//$_SESSION['user_id'] = $userID;
if($_SESSION['user_type'] == 1){
header('location: index.php?controller=admin&action=adminhomepage');
}else{
header('location: index.php?controller=view&action=homepage');
}
} else{
header('location: index.php?controller=user&action=login');
}
}
require_once('View/login.php');
break;
}
public function login($username, $password){
$sql = "SELECT * FROM user WHERE UserName='$username' AND Password='$password'";
$this->execute($sql);
return $this->getAllData(array($username,$password));
}