1

I'm working with Laravel 6, and my session driver is file. I've faced a 419|page expired when I submit a form with post action and after tracing the codes I found out the session will restart after submission. Everything is good on local but on the server I've got this issue. I tried with a raw Laravel project and it worked!

I've already checked directory permission, config/session.php,.env file.

.env

SESSION_DRIVER=file
SESSION_LIFETIME=120

config/session.php

'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false

Tnx for responding.

the problem is not because of CSRF token, it's session's fault. evry time a new session and new token will be started so the token thet I send from input will be checked with another token !!!

5
  • are you passing @csrf in your form? Commented Feb 10, 2020 at 11:32
  • yes I've already add this Commented Feb 10, 2020 at 12:12
  • You might try running php artisan cache:clear && php artisan config:cache on the server. Commented Feb 10, 2020 at 12:13
  • I've already tried them yet it not workes Commented Feb 10, 2020 at 13:16
  • i am also getting this issue on local server, how it will fix? Commented Aug 30, 2020 at 4:01

1 Answer 1

0

If your form is in a blade, after starting the <form>, add a csrf field by putting @csrf.

If you're sending the POST request from somewhere else (i.e. from some other domain/subdomain that is not project domain) you may want to disable CSRF check by adding it in VerifyCsrfToken.php (\app\Http\Middleware\VerifyCsrfToken.php) like this:

class VerifyCsrfToken extends BaseVerifier
{
    protected $except = [
        // Place your URIs here
    ];
}
Sign up to request clarification or add additional context in comments.

2 Comments

I have it, tnx.
nope, I mean when I asked The Q I had the CSRF token :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.