|
PHP复制代码 function _captcha ()
{
if($this->session->userdata('captcha') != "")
{
$this->_del_captcha ();
}
$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url ().'captcha/',
'font_path' => './fonts/arial.ttf',
'img_width' => '80',
'img_height' => 30,
'expiration' => 7200
);
$cap = create_captcha ($vals);
$this->session->set_userdata('captcha',$cap['word']);
$this->session->set_userdata('captcha_url',$cap['time']);
return $cap['image'];
}
复制代码PHP复制代码 function _del_captcha () {
$path = "./captcha/".$this->session->userdata('captcha_url').".jpg";
$this->load->helper('file');
unlink($path);
}
复制代码
登录成功后
PHP复制代码
$this->_del_captcha();
$this->session->set_userdata(*,*);
$this->session->unset_userdata('captcha');
$this->session->unset_userdata('captcha_url');
复制代码
刷新的时候执行一下 _del_captcha 即可
这样由于验证码看不清 更换的时候不会生成多张验证码 只会有一张
|
|