Laravel 5 and Internet Explorer : Token Mismatch

后端 未结 4 1198
小鲜肉
小鲜肉 2021-01-11 22:45

My Laravel5 website uses csrf tokens to prevent CSRF attacks. On Chrome and Firefox, eveything works fine.

I submitted the site for my client to test and, when he us

相关标签:
4条回答
  • 2021-01-11 23:11

    I am not sure about your case. But I just encountered same issue today. Only IE got problem. FF and chrome works fine.

    I then realize that it's the time/date at the server is wrong. Set the server to current date, then everything is working now.

    I guess it's because the server will set cookie expiration according to its own time, and at the client, IE will delete the cookies immediately if the server lags behind. Just my guess.

    Hope it can solve your case too. Good luck.

    0 讨论(0)
  • 2021-01-11 23:20

    In my case the problem was the server time. I read somewhere that if the server time is older than the client, IE clear the cookies. Then I notice that the server time here was 8 hours late. After fixing this, the Token Mismatch Error disappear.

    0 讨论(0)
  • 2021-01-11 23:28

    I had the same problem and what fixed it for me was to edit my .htaccess expire settings to:

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault A0
        ExpiresByType text/html A0
        # Set up caching on media files for 1 year
        <FilesMatch "\.(jpg|png|gif|js|css|ico|woff|woff2|eot|svg|ttf)$">
            ExpiresDefault A31536000
        </FilesMatch>
    </IfModule>
    

    Before, my ExpiresDefault was A31536000 and I did not have the ExpiresByType text/html.

    0 讨论(0)
  • 2021-01-11 23:32

    I faced the same issue, and it was due to P3P error. Faced the issue on Edge (Windows 10).

    I did a lot of research, and finally got it fixed.

    All you have to do is create a new middleware and udpate the handle function to,

    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;
    }
    

    Explained it in detail at

    https://robinz.in/csrf-token-session-error-with-laravel-on-ie-edge/

    0 讨论(0)
提交回复
热议问题