久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      TP6驗證碼驗證失敗的原因以及解決辦法

      TP6驗證碼驗證失敗的原因以及解決辦法

      首先使用Composer安裝think-captcha擴展包:

      composer require topthink/think-captcha

      控制器引入

      use thinkcaptchafacadeCaptcha;

      生成驗證碼

      public function verify() {     return Captcha::create(); }

      驗證驗證碼

      if( !Captcha::check($vercode)) {     return json(['code'=>1001, 'msg'=>'驗證碼錯誤'); }

      check的方法

      /**  * 驗證驗證碼是否正確  * @access public  * @param string $code 用戶驗證碼  * @return bool 用戶驗證碼是否正確  */ public function check(string $code): bool {     if (!$this->session->has('captcha')) {         return false;     }       $key = $this->session->get('captcha.key');       $code = mb_strtolower($code, 'UTF-8');       $res = password_verify($code, $key);       if ($res) {         $this->session->delete('captcha');     }       return $res; }

      從以上check方法可以看出來驗證碼驗證是需要session的,而Thinkphp6默認(rèn)是不開啟的,需要根據(jù)手冊初始化一下

      在應(yīng)用app目錄下找到全局中間件middleware.php文件,把下面注釋的代碼thinkmiddlewareSessionInit::class開啟就行了

      // 全局中間件定義文件 return [     // 全局請求緩存     // thinkmiddlewareCheckRequestCache::class,     // 多語言加載     // thinkmiddlewareLoadLangPack::class,     // Session初始化      thinkmiddlewareSessionInit::class ]

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號