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