我有這樣的代碼:PHP驗證碼會話一點兒也不更新
captcha.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
c頌歌,而不是正在顯示的電流。
我該怎麼辦?
謝謝,你是如此吧! – user1936192