【问题标题】:CI: Ion Auth Error randomly appears sometimes and I can't figure out whyCI:Ion Auth Error 有时会随机出现,我不知道为什么
【发布时间】:2011-08-11 04:41:04
【问题描述】:

将 Ion Auth 与 Code Igniter 2.0 和 PHP 5.2 一起使用时出现以下错误

ErrorException [ Notice ]: Undefined property: Practice::$ion_auth
SYSDIR/core/Model.php [ 50 ]

这是该行的代码:

45      * @access private
46      */
47     function __get($key)
48     {
49         $CI =& get_instance();
50         return $CI->$key;
51     }
52 }
53 // END Model Class
54 
55 /* End of file Model.php */ 

关于这个错误的奇怪之处在于,当我尝试访问一个“受限”页面而没有先访问同一域上的非受限页面时,它似乎会蔓延。也就是说,如果我打开浏览器并输入 example.com/restricted - 我会收到错误消息。但是,如果我输入 example.com/login 然后(即使我没有正确登录)转到 example.com/restricted,它将让我进入或正确重定向我(取决于我是否实际登录)。

我终其一生都无法弄清楚是什么引发了这个问题。这是我使用 Ion Auth 库的一些控制器的构造函数示例:

class Home extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->library('firephp');

        //ION
        $this->load->library('Ion_auth');
        $this->load->library('session');
        $this->load->library('form_validation');
        $this->load->database();
    }

class Practice extends CI_Controller {

    var $user;
    var $game;

    function __construct() {
        parent::__construct();

        // ION Auth
        $this->load->library('Ion_auth');
        $this->load->library('form_validation');
        $this->load->library('session');

        // Defaults
        $this->load->helper('url');
        $this->load->library('firephp');

        // Models
        //$this->load->model('Ion_auth_model');
        //$this->load->model('Player');
        $this->load->model('Practice_Game');



        // User must be logged in to use this controller
        // If user is logged in then we get his info as a class variable
        if ($this->ion_auth->logged_in()) {
            $this->user = $this->ion_auth->get_user($this->session->userdata('user_id'));
        } else {

【问题讨论】:

标签: php codeigniter authentication ion-auth


【解决方案1】:

我遇到了同样的问题。当记住的登录被自动登录并且 ion auth 尝试使用一些尚未加载的属性时,就会出现此问题。

您可以查看此拉取请求和以下提交:

https://github.com/benedmunds/CodeIgniter-Ion-Auth/pull/46 https://github.com/benedmunds/CodeIgniter-Ion-Auth/commit/ba6d09299cd7469835ab3ad7fb1a4333de88d468

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-09
    • 1970-01-01
    • 1970-01-01
    • 2019-12-30
    • 2012-12-19
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多