我有这个代码:
验证码.php:
session_start();
class Captcha {
protected $code;
protected $width = 35;
protected $height = 150;
function __construct() {
$this->code = substr(sha1(mt_rand()), 17, 6);
$_SESSION['captcha'] = $this->code;
}
function getCode(){
return $this->code;
}
function showImage() {
// here comes the code that builds the image.
// it works fine!
}
}
$image = new Captcha();
$image->showImage();
在我的登录表单中,我有:
<iframe src="includes/captcha.php" frameborder="0" height="65" width="180"></iframe>
如果我print_r($_SESSION)
,$_SESSION['captcha']
总是延迟:它包含以前的captcha
代码,而不是正在显示的当前代码。
我应该怎么办?