<div class="cnblogs_code">
}
public function Index(){
session("user",""); //清空session
$mobile = parent::isMobile();
if($mobile=="true"){
$this->display(Wap_Login);
}else{
$this->display(Login);
}
}
public function Login(){
if (IS_AJAX) {
$username = I('param.username');
$password = I('param.password');
$user = M("cuser");
$res=$user->where("login_id='{$username}' OR phone='{$username}'")->find();
if (!empty($res) && $res['password']==md5($password)) {
$this->LoginSession($res); <span style="color: #ff00ff">//存入session,把$res的一条数据存入session以方便后面使用</span>
$status=1; //<a href="https://www.jb51.cc/tag/yonghuming/" target="_blank" class="keywords">用户名</a>正确,<a href="https://www.jb51.cc/tag/mimazhengque/" target="_blank" class="keywords">密码正确</a>。
}elseif(!empty($res) && $res['password']!==md5($password)){
$status=2; //<a href="https://www.jb51.cc/tag/yonghuming/" target="_blank" class="keywords">用户名</a>正确,密码不正确。
}elseif(empty($res)){
$status=3; //<a href="https://www.jb51.cc/tag/yonghuming/" target="_blank" class="keywords">用户名</a>不存在。
}
$this->ajaxReturn($status);
exit();
}
$mobile = parent::isMobile();
if($mobile=="true"){
$this->display(Wap_Login);
}else{
$this->display(Login);
}
}
//调用session方法
public function LoginSession($user_info){
session('[regenerate]'); //会话([再生])
session("user",$user_info);
}
}