Home >php教程 >php手册 >php中cookie操作实例

php中cookie操作实例

WBOY
WBOYOriginal
2016-06-13 09:28:491635browse

php中cookie操作实例

   做了一个cookie操作的实例,第一个文件login_frm.PHP这个是登录窗口。

  代码 1

  2

  3

  4

  5

  6

 

  10

  11

  第二个文件login.php这个是处理登录

  1

  2 if($_POST['username'] = 'admin')

  3 {

  4 setcookie('haha','gogo');

  5 header("location:index.php");

  6 }

  7 ?>

  第三个文件index.php再看下效果

  1

  2 if($_COOKIE['haha'] == 'gogogo')

  3 {

  4

  5 echo $_COOKIE['haha'];

  6 echo'你设置了cookie';

  7 }

  8 else

  9 {

  10 echo'你没有设置cookie';

  11 }

  12 ?>

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