CodeIgniter set_userdata()触发服务器500错误
- CodeIgniter问题:服务器500错误。 每当我调用set_userdata()函数时,它都会触发Server 500错误。登录示例代码如下。我在SiteGround上托管它。如果我删除set_userdata函数,代码工作正常,除非登录不起作用。
<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); // LOGIN MODEL class Login_model extends CI_Model{ function __construct(){ parent::__construct(); } // VALIDATE METHOD public function validate(){ // grab user input $username = $this->security->xss_clean($this->input->post('username')); $password = $this->security->xss_clean($this->input->post('password')); $this->db->where('username', $username); $this->db->where('password', sha1($password)); $this -> db -> where('activated', 'yes');// Run the query<br> $query = $this->db->get('user_account');// Let's check if there are any results if($query->num_rows == 1)// If there is a user, then create session data { $row = $query->row(); $data = array( 'id' => $row->serial, 'name' => $row->name, 'email' => $row->email, 'password' => $row->password, 'type' => $row->type, 'address' => $row -> address, 'phone' => $row -> phone, 'pic' => $row -> pic,<br> 'validated' => true ); $this->session->set_userdata($data); return true; }// If the previous process did not validate return false;// then return false. } }
?>
你在application/config/autoload.php中加载会话库 –
;自动加载“会话”库,如果还没有这样做。 – Arunu
@Adarsh是啊我已经加载会话库.. – user3200990