blog.php
cookie頁面
login.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 "登陸失敗"; } }?>
回複內容:
blog.php
cookie頁面
login.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 "登陸失敗"; } }?>
setCookie("username",$username,$time,"/");
echo $username;//列印使用者名稱