我正在尝试使用以下代码扩展表单验证库:
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
我试图在构造时加载会话库,但又遇到了错误。是否有任何选项可以在内部使用会话库,或者我应该将会话中的值作为第二个参数传递?