我試圖用這個代碼擴展的表單驗證庫:笨擴展庫+使用另一個庫
class MY_Form_validation extends CI_Form_validation {
public function __construct() {
parent::__construct();
}
public function check_captcha($captcha)
{
if ($captcha == $this->session->userdata('captcha'))
{
return TRUE;
} else
{
$this->form_validation->set_message('check_captcha', "Please copy captcha again.");
return FALSE;
}
}
}
當我運行驗證我得到這個錯誤:
Message: Undefined property: MY_Form_validation::$session
Filename: libraries/MY_Form_validation.php
我試圖加載在構造會話庫,但我得到了錯誤。有沒有任何選項可以使用會話庫裏面,或者我應該將會話的值作爲第二個參數傳遞?
可能重複的[CodeIgniter客戶控制器類說會話是未定義](http://stackoverflow.com/questions/3817366/codeigniter- customer-controller-class-say-session-is-undefined) – Prasanth
這不是這樣的......我有自動加載所有需要的圖書館和助手在配置。我在說擴展Libraray不是關於控制器:) – DeiForm