thinkphp session 取不到验证码
//查询验证码
function checklogin(){
$data=$_session['verifycode'];
echo $data;
}
//生成验证码
public function verify(){
import(@.org.image);
$image=new image();
$image->buildimageverify(6, 5);
}
验证码生成了,但是控制器里面session就是取不到验证码
static function showadvverify($type='png', $width=180, $height=40, $verifyname='verifycode') {
$rand = range('a', 'z');
shuffle($rand);
$verifycode = array_slice($rand, 0, 10);
$letter = implode( , $verifycode);
$_session[$verifyname] = $verifycode;
略。。。。。。。
thinkphp session 验证码 分享到:
------解决方案--------------------
1、确认程序文件没有 bom 头
2、操作 session 应该用 tp 提供的方法
3、确认你的代码和工作过程与 tp 约定的一致
tp 提供了验证码生成类,也提供了表单验证。并不需要自己写代码,只需填写参数就可以了