使用Laravel 5 App在Edge和IE 11中使用TokenMismatchException

时间:2016-08-17 13:32:59

标签: laravel laravel-5.1

我开发了一个laravel 5应用程序,除了IE和Edge之外,在所有其他浏览器上运行良好。我在所有表单提交上得到TokenMismatchException。我阅读了这篇博文https://robinz.in/csrf-token-session-error-with-laravel-on-ie-edge/

并实施以下内容作为尝试解决问题,但仍然无效:

  1. 创建了一个中间件

    namespace App\Http\Middleware;
    
    use Closure;
    
    class IeFix
    {
        /**
         * Handle an incoming request. Fix session error with Laravel on IE/Edge
         *
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  \Closure  $next
         * @return mixed
         */
        public function handle($request, Closure $next)
        {
            $response = $next($request);
            $response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
            return $response;
        }
    }
    
    1. 将类添加到应用程序的全局HTTP中间件堆栈中,如下所示。 protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\IeFix::class, ]; 但我仍然在IE和Edge上得到同样的错误?我该怎么做才能解决这个问题?

0 个答案:

没有答案