【发布时间】:2018-11-22 15:53:03
【问题描述】:
我的 codeigniter 会话有一些问题。我正在使用 CodeIgniter-3.1.8。我在配置中的 autoload.php 中加载了会话
$autoload['libraries'] = array('database', 'session');
但它会显示类似Unable to locate the specified class: Session.php 的错误。
然后我将它从 autoload.php 中删除并加载到控制器中。
public function __construct() {
parent::__construct();
$this->load->library('session');
}
并尝试在我的控制器中设置flashdata。但现在它显示像Undefined property: controller::$session 这样的错误。我已经将 config.php 中的 encryption_key 和会话存储驱动程序设置为数据库。
这是我的控制器示例代码:
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('session');
}
public function register() {
$data = $this->input->post();
$result = false; //$this->Home_model->register($data);
if($result){
$this->session->set_flashdata('success', 'Registration successful');
$this->session->set_flashdata('form', 'login');
}
else {
$this->session->set_flashdata('failure', 'An error occured, please try again');
$this->session->set_flashdata('form', 'register');
}
}
}
这个问题来了,当我尝试加载模型时
【问题讨论】:
标签: php codeigniter session