TP6 令牌无效 解决不了,请大神帮忙!

浏览:9407 发布日期:2019/12/23 分类:ThinkPHP6专区 关键字: 令牌无效 token 校验token
一直提示 ‘令牌无效’,<form action="/admin/upload" enctype="multipart/form-data" method="post">
    <input type="file" name="image" /> <br>
    <input type="text" name="name" /> <br>
    <input type="text" name="email" /> <br>
    <input type="text" value='{:token()}' name="__token__"  style="width:400px;"><br>
    <input type="submit" value="上传" />

</form>
没提交前 能dump到

array:2 [▼
"testSession" => "testValue"
"__token__" => "36ee48ab50126f38dedb8f0398599c30"
]


中间件也开启了。    // Session初始化,不启用则
    \think\middleware\SessionInit::class,
    // 定义Token中间件
    \think\middleware\FormTokenCheck::class,
提交表单后,没有了。一直提示无效令牌
dump出来的session 为 nullnamespace app\admin\controller;

use app\BaseController;
use think\facade\Session;
use think\Request;
use think\exception\ValidateException;

class Upload extends  BaseController
    { public function Index(Request $request){

   dump (Session::all()); //dump 不到。
    $check = $request->checkToken('__token__');

    if(false === $check) {
        echo '令牌无效';
//        throw new ValidateException('invalid token');
    }
请大神指点。谢谢。。
最佳答案
评论( 相关
后面还有条评论,点击查看>>