<?php
if(isset($_POST["username"])){
//之前进行一些用户登陆的判断
setcookie("username", $_POST["username"]);//设置用户名COOKIE,60秒后过期
setcookie("password", $_POST["password"]);
//完成后再根据需要进行转向
}
if($_COOKIE){
echo "你的用户名为:".$_COOKIE["username"]."\n<br>密码为:".$_COOKIE["password"];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<form name="form1" method="post" action="">
  用户名
  <input name="username" type="text" id="username" value="admin">  
  <br>
  密 码
  <input name="password" type="text" id="password" value="admin">
  <input type="submit" name="Submit" value="登陆">
</form>
</body>
</html>