Soot0927
2016-11-30 03:49
采纳率: 33.3%
浏览 1.1k
已采纳

THINKPHP 3.1本地登陆可以,放到服务器无法登陆

求解,SESSION,COOKID 都可以输出,RUNTIME也清空了,数据库登陆日记也有写入。

求大神!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • Soot0927 2016-11-30 04:02
    已采纳

    是自己数据库权限不足。。。醉了

    点赞 打赏 评论
  • Soot0927 2016-11-30 03:50
        $username = $_POST['username'];
        $password = $_POST['password'];
    
    
        if ($username == '' || $password == '') {/* 为空跳到默认网关 */
            $this->redirect('Admin/Public/login');
        }
    
    
        /*if (empty($_POST['verify'])) {
            echo "<script>history.go(-1);alert('验证码必须');</script>";
        }
    
       if (session('verify') != md5($_POST['verify'])) {
            $this->error('验证码错误!');
    
        }*/
    
        /* 判断帐号、密码] */
        $User = M("User")->where(array('username' => $username))->find();
        if (!$User || md5($password) != $User['password']) {
            $this->error("用户名或密码错误!", '', 20);
        }
    
        if (!$User['status']) {
            /* status为0表示锁定状态 */
            $this->error("帐号被锁定,请稍后再试!", '', 20);
        } else {
            /* 身份验证通过 */
            $date['last_login_ip'] = $User['login_ip'];
           // $date['login_ip'] = get_client_ip();
            $date['login_ip'] = $_SERVER['REMOTE_ADDR'];
            $date['last_login_time'] = time();
            M("User")->where(array('uid' => $User['uid']))->save($date);
            //session('verify', null); // 删除name
            /* 写Session */
            session(C('AUTH_CONFIG.USER_AUTH_KEY'), $User['uid']);
            session('username', $User['username']);
            session('loginUserName', $User['username']);
            session('userid', $User['uid']);
    
            /* 写日志 */
            $account = session('username');
            $titile = "系统登陆";
            $new_content = "";
            $old_content = "";
            $module_name = MODULE_NAME;
            $function_name = ACTION_NAME;
            addlog($account, $titile, $new_content, $old_content, $module_name, $function_name);
            /* 写Cookies记住登录 */
            if (I('remember') == '1') {
                cookie('uid', session(C('AUTH_CONFIG.USER_AUTH_KEY')));
                cookie('username', session('username'));
            }
            $url = U("Admin/Index/index");
            $this->success("登录成功!", $url, 20);
    
    
    
    点赞 打赏 评论

相关推荐 更多相似问题