时间:2021-07-01 10:21:17 帮助过:50人阅读
登录页
prepare("select id,username,password from user where username=? and password=?");
$stmt->execute(array($_POST['username'],($_POST['password'])));
if($stmt->rowCount()>0){
list($id,$username)=$stmt->fetch(PDO::FETCH_NUM);
$time=time()+24*60*60;
setCookie("uid",$id,$time,"/");
setCookie("username",$username,$time,"/");
setCookie("isLogin",1,$time,"/");
echo '';
}
else{
echo "登陆失败";
}
}
?>
直接这样$_COOKIE['username'] 不能打印出来登陆的用户名啊 我想用这个用户名怎么办呢?
登录页
prepare("select id,username,password from user where username=? and password=?");
$stmt->execute(array($_POST['username'],($_POST['password'])));
if($stmt->rowCount()>0){
list($id,$username)=$stmt->fetch(PDO::FETCH_NUM);
$time=time()+24*60*60;
setCookie("uid",$id,$time,"/");
setCookie("username",$username,$time,"/");
setCookie("isLogin",1,$time,"/");
echo '';
}
else{
echo "登陆失败";
}
}
?>
你得先在登录成功的时候写一下COOKIE,写完了再访问新的页面,你的php代码才能读到它
没人啊。。。。。。。。。。