I know my issue is not because of Laravel but most likely the php configuration (sessions), but I am not sure what to check. I was running this particular project on a homestead
and it was fine. Now after I submit a form (it's a steps controller, post
form -> go to step 2 etc.) and refresh the page my csrf token is invalid.
I thought it was because of session lifetime and such or generation of new token, but no .. the token is the same, but I still get TokenMismatchException
after I refresh the page.
The environment is pretty much the same as the homestead (nginx (latest), php(5.6, I don't know what homestead had) ). The logins work fine, I stay logged in while browsing, but when I go through the steps this happens ..
Problem & Solution:
As per comments bellow where I forgot to update, I found out the problem was actually the fact, that the dev server was forced through cloudflare, but the base url in Laravel was left at http://...
- I just added to AppServiceProvider
$this->app['request']->server->set('HTTPS', true);
and it wasn't doing the verification error.
As per comments bellow where I forgot to update, I found out the problem was actually the fact, that the dev server was forced through cloudflare, but the base url in Laravel was left at http://...
- I just added to AppServiceProvider
$this->app['request']->server->set('HTTPS', true);
and it wasn't doing the verification error.
Do you send a csrf token with the form you submit? If not: how did you build up your form, with FormBuilder or Html?
FormBuilder
In the formbuilder the CSRF token is already posted so it's not needed to send it.
Html
<form method="POST" action="/profile">
{{ csrf_field() }} //This is what you need!
...
</form>
You did not provide an error log, check in your laravel project for storage/logs and then provide us the error so we can help you.