douhao8456 2019-03-08 11:49
浏览 79

在null上调用成员函数userdata()

please help me!I don't know how do . I need your help

Message: Call to a member function userdata() on null

Filename: /home/xxxxx/xxxxx.x.it/xxx/application/libraries/Auth.php

Line Number: 23

Backtrace:

( page) Function: get_user

(controller) Function: _costruttor

    function get_user() {
    $name = $this->session->userdata('id');
    if ($name) {
    $this->obj->db->where("id",$this->obj->session->userdata("id"));
        $this->obj->db->where("ip",$this->obj->input->ip_address());
        $user= $this->obj->db->get("u_user")->row_array();
        if ($utente) {
            $this->user = $user;
        }
    }



class MY_Controller extends CI_Controller {
function _costruttor() {
    parent::__construct();
    $this->load->library("encrypt");
    $unlocked = array('login');
    $this->page->get_user();
    $this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
    if (!$this->page->get_user() AND ! in_array(strtolower(get_class($this)), $unlocked)) {
        $this->session->set_userdata('back_url', current_url());
        redirect('login/');
    }
}

}

  • 写回答

2条回答 默认 最新

  • dtqpw68806 2019-03-08 11:51
    关注

    I think you have forgot to include session library.

    There are two ways to solve this:

    1) Include session library dynamically in your page.

    Insert this

    $this->load->library('session');
    

    Before the line.

    $name = $this->session->userdata('id');
    

    2) Adding it in autoload libraries:Another way of doing this is:

    If you required it globally, include it in

    applications/config/autoload.php

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

    Assuming that database and session are required globally.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题