Skip to content

Commit

Permalink
修正session前缀
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Jul 6, 2016
1 parent 5743f68 commit 0c55455
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ public function check($code, $id = '')
{
$key = $this->authcode($this->seKey) . $id;
// 验证码不能为空
$secode = Session::get($key);
$secode = Session::get($key, '');
if (empty($code) || empty($secode)) {
return false;
}
// session 过期
if (time() - $secode['verify_time'] > $this->expire) {
Session::delete($key);
Session::delete($key, '');
return false;
}

if ($this->authcode(strtoupper($code)) == $secode['verify_code']) {
$this->reset && Session::delete($key);
$this->reset && Session::delete($key, '');
return true;
}

Expand Down Expand Up @@ -198,8 +198,8 @@ public function entry($id = '')
$secode = [];
$secode['verify_code'] = $code; // 把校验码保存到session
$secode['verify_time'] = time(); // 验证码创建时间
Session::set($key . $id, $secode);
Session::set($key . $id, $secode, '');

ob_start();
// 输出图像
imagepng($this->_image);
Expand Down

0 comments on commit 0c55455

Please sign in to comment.