Home >php教程 >php手册 >PHP学习系列之会话控制

PHP学习系列之会话控制

WBOY
WBOYOriginal
2016-06-06 19:57:121066browse

欢迎进入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");

  ?>

  

  name:

  

  

  

  /**

  * 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] 

PHP学习系列之会话控制

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn