首页 > 解决方案 > Codeigniter 登录(会话)问题

问题描述

我的网站托管在 PHP 版本(5.6)的 VPS 服务器上。我面临登录问题。如果我清除浏览器缓存,那么我可以登录。问题是由于会话值为空,会话将我重定向回登录页面。我的会话值存储在数据库中。我的登录控制器代码如下。

if ($this->input->post()) {
    // echo '<br>hiii';
    $username = trim($this->input->post('user_id'));
    $password = trim($this->input->post('password'));
    $where = "(mobile_number = '".$username."' OR email = '".$username."') AND password = '".$password."' AND deactive='0'";
    $where = "(mobile_number = '".$username."' OR email = '".$username."' AND deactive='0')";
    $where_or = array('password' => $password);
    $result = $this->mdgeneraldml->select('*', 'tbl_user', $where, '', '', '', '', '', '', '', '', '', '', $where_or);
    if (count($result) > 0) {
        if ($result[0]['profile_pic'] != '') {
            $profile_img = base_url() . 'img/users/' . $result[0]['profile_pic'];
        } else {
            $profile_img = base_url() . 'img/default_user.png';
        }
    }
}

会话库在 config/autoload.php 中加载

$autoload['libraries'] = array('database','session', 'email');

标签: phpauthenticationsessioncodeigniter-3vps

解决方案


请检查您的codeigniter版本,如果是最旧的版本,请尝试将系统目录替换为您的项目系统目录,它将解决问题


推荐阅读