PHP用cookie实现自动登陆
2 //自动登陆
3 if($_COOKIE["userName"] && $_COOKIE["password"] )
4 {
5 //获取登录信息传入数据库进行验证
6
7 //打印登录信息
8 echo '用户名:'.$_COOKIE["userName"].'
密码:'.$_COOKIE["password"];
9 }
10
11
12
13 //提交表单
14 if($_GET['submit'])
15 {
16 // echo 'login。。';
17 //用户勾选"记住密码"选项,将用户登陆信息写入cookie里
18 if($_GET['remember'] == 'on')
19 {
20 setcookie("userName",$_GET["userName"],time()+3600);
21 setcookie("password",$_GET["pass"],time()+3600);
22 }
23
24 //刷新页面
25 echo '<script>location.href="cookie.php"</script>';
26 }
27
28 //退出登陆
29 if($_GET['out'])
30 {
31 //设置cookie超时
32 setcookie("userName",$_GET["userName"],time()-3600);
33 setcookie("password",$_GET["pass"],time()- 3600);
34
35 //刷新页面
36 echo '<script>location.href="cookie.php"</script>';
37 }
38 ?>
39
40 form action="cookie.php" method="get">
41 table border="1" cellspacing="" align="center" background="" bordercolor="blue" rules="none">
42
43 tr bgcolor="cccccc" align="left" >th >th>th >输入信息th>tr>
44 tr>td>用户名td>td>input type="text" name="userName" >td>tr>
45 tr>td>密码td>td>input type="password" name="pass">td>tr>
46 tr>td>input type="checkbox" name="remember">记住密码td>td align="right">input type="submit" value="登陆" name="submit">td>tr>
47 table>
48 a href="cookie.php?out=out">退出登陆a>
49 form>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software