gpt4 book ai didi

php - CI : Ion Auth Error randomly appears sometimes and I can't figure out why

转载 作者:搜寻专家 更新时间:2023-10-31 21:44:43 24 4
gpt4 key购买 nike

将 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 */

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

我终究无法弄清楚是什么触发了这个问题。下面是我的一些使用 Ion Auth 库的 Controller 的构造函数示例:

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 {

最佳答案

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

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

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

关于php - CI : Ion Auth Error randomly appears sometimes and I can't figure out why,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5759462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com