首页 > Web开发 > 详细

php -- Cookie

时间:2014-05-25 03:08:57      阅读:395      评论:0      收藏:0      [点我收藏+]

----- 013-form.html -----

bubuko.com,布布扣
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta http-equiv="content-type" content="text/html; charset=utf-8">
 5     <title>一个PHP网页</title>
 6 </head>
 7 <body>
 8 <center>
 9     <form action="013-cookie.php">
10         用户名:<input type="text" name="username"/><br/>
11&nbsp;&nbsp;码:<input type="text" name="password"/><br/>
12         <input type="submit" name="submit" value="登录"/>
13         <input type="reset" name="reset" value="重置"/>
14     </form>
15 </center>
16 </body>
17 </html>
bubuko.com,布布扣

----- 013-cookie.php -----

bubuko.com,布布扣
 1 <?php
 2     setcookie("username", $_GET[‘username‘], time()+3600);
 3     setcookie("password", $_GET[‘password‘], @mktime(0,0,0,1,1,2015));//UNIX时间戳 2015.1.1过期
 4     //设置Cookie前不可以传送任何一个字符甚至是一个空格
 5 ?>
 6 <!DOCTYPE html>
 7 <html>
 8 <head>
 9     <meta http-equiv="content-type" content="text/html; charset=utf-8">
10     <title>一个PHP网页</title>
11 </head>
12 <body>
13 <?php
14     print_r($_COOKIE);echo "<br/>";
15     print_r($_GET);
16     echo "现在的Cookie内容是:<br>";
17     echo "用户名:", $_COOKIE[‘username‘], "<br/>";
18     echo "密码:", $_COOKIE[‘password‘], "<br/>";
19 ?>
20 </body>
21 </html>
bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

php -- Cookie,布布扣,bubuko.com

php -- Cookie

原文:http://www.cnblogs.com/baijifeilong/p/3750409.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!