勾选自动登录不起作用
勾选了自动登录再打开还是显示请登录是怎么回事
doLogin.php
<?php
//session_start();
require_once '../include.php';
$username=$_POST['username'];
$password=md5($_POST['password']);
$verify=$_POST['verify'];
$verify1=$_SESSION['verify'];
$autoFlag=$_POST['autoFlag'];//自动登录
if($verify==$verify1){
$sql="select * from imooc_admin where username='{$username}' and password='{$password}'";
$row=checkAdmin($sql);
if($row){
if($autoFlag){
setcookie("adminId",$row['Id'],time()+7*24*3600);
setcookie("adminName",$row['username'],time()+7*24*3600);
}
$_SESSION['adminId']=$row['id'];
$_SESSION['adminName']=$row['username'];
alertMes("登录成功","index.php");
}else{
alertMes("登录失败,重新登录","login.php");
}
}else{
alertMes("验证码错误","login.php");
}