在我的php中我有这段代码,看看用户是否已登录
$auth=new auth();
$username = $auth->loggedIn();
global $crt_usr;
if(!$username) { header("Location: ".$config_live_site."/login.php?loc=account_info.php"); exit(0); }
$smarty->assign("username",$username);
$usr = new users();
$user = $usr->getUser($crt_usr);
$smarty->assign("user",$user);
我有和这个插入箭头
function get_user_id()
{
$userid = NULL;
if (isset($_COOKIE['userid']))
{
$userid = $_COOKIE['userid'];
}
return $userid;
}
我的数据库中的用户ID字段名称是" id"
答案 0 :(得分:0)
您可以设置具有您的用户ID的会话并将其放入get_user_id()
函数
if (isset($_SESSION['userid']))
{
$userid = $_SESSION['userid'];
}