下面是兩個頁面 一個是登入頁面 登入後跳轉到blog.php頁面 這個頁麵包含了下面的cookie頁面 為什麼跳轉到blog.php後顯示沒有登入呢? 應該是登入的才對啊
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頁面
回複內容:
下面是兩個頁面 一個是登入頁面 登入後跳轉到blog.php頁面 這個頁麵包含了下面的cookie頁面 為什麼跳轉到blog.php後顯示沒有登入呢? 應該是登入的才對啊
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頁面
$time=time()*24*60*60 改為 $time=time() +24*60*60
使用者關閉了瀏覽器緩衝功能的話cookie就不好時了,建議用session
就是可能你關閉了瀏覽器的cookie緩衝