会话控制
2018-05-08 本文已影响0人
你从长安来
一、_COOKIE
设置cookie:
setcookie('name' , 'zhangsan' , time()+3, '/');
//cookie名,对应值,有效时间(s),作用域
销毁cookie:
setcookie('name', ' ' , time()-1, '/');
登录的小实现
dologin.php
if($_GET['username']=='zhaihuihui' &&$_GET['pwd']=='123')
{
setcookie('username',$_GET['username'],time()+6,'/');
echo '登录成功';
}else
{
echo '用户名或密码错误';
}
login_.php
<html>
<body>
<form action="dologin.php">
username:<input type = "text" name= "username" /><br>
password:<input type = "password" name="pwd" /><br>
<input type = "submit" value="提交" />
</form>
</body>
</html>