form页面
用户名
密码
记住密码
session_start();
function p($arr){
echo "
";
print_r($arr);
echo "
";}
p($_SESSION);
p($_COOKIE);
?>
登录页面
function p($arr){
echo "
";
print_r($arr);
echo "
";}
session_start();
//p($_POST);
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
if($_POST['jizhu']){
setcookie('username',$_POST['username'],time()+60);
setcookie('password',$_POST['password'],time()+60);
}
header("location:form.php");
用户信息页面
session_start();
echo "先关闭浏览器,在访问form.php 试试,然后 点推出在关闭浏览器试试";
p($_SESSION);
p($_COOKIE);
if(empty($_SESSION['username'])){
if(empty($_COOKIE['username'])){
echo "请先登录";exit;
}else{
$_SESSION['username'] = $_COOKIE['username'];
}
}
function p($arr){
echo "
";
print_r($arr);
echo "
";}
?>
2131231231
推出页面
session_start();
unset($_SESSION['username']);
unset($_SESSION['password']);
setcookie('username','',0);
setcookie('password','',0);
header("location:form.php");
?>
修改用户信息页面
session_start();
if(empty($_SESSION['username'])){
echo "请先登录";
}else{
echo "这里是信息";
}
?>