欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 header("Content-type:text/html;charset=utf-8"); ? form method="post" action="demo_setCookie2.php" name:input type="text" name="username" input type="submit" value="登录" /form ?php /
欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入
header("Content-type:text/html;charset=utf-8");
?>
/**
* demo_setCookie2.php
*/
if(isset($_POST["username"]) && $_POST["username"] == "benjamin"){
//正确,生成一个cookie 再跳转
setCookie("username","Benjamin");
header("Location:demo_setCookieSuccess.php");
}else{
header("Location:demo_setCookie.php");
}
?>
/**
* demo_setCookieSuccess.php
*/
header("Content-type:text/html;charset=utf-8");
if (isset($_COOKIE["username"])) {
echo "欢迎光临".$_COOKIE["username"];
}else{
echo "非法登录";
}
?>
[1] [2]