Laravel 5.1 problem with csrf_token

Asked

Viewed 189 times

0

I’m having a problem on my site made in Laravel, it happens the following my application in Laravel is not returning the session Token that would be {{ csrf_token() }} when I execute an action as register or log in it returns me the following error:inserir a descrição da imagem aqui

This error happens only on the production server, trying to resolve ended up identifying that when I am accessing the site on the production server the client does not receive the session token that should be in cookies as in the images below:

Token of the developing session: Token da sessão em desenvolvimento Token of the production session: Token da sessão em produção As you can see, it is as if the application does not return the session token on the production server, even so it is sent a token in the request that is different from the one generated by the application and generates the error that I reported above.

Below my session settings on file .env SESSION_DRIVER=file

My Session.php

<?php

return [
    'driver' => env('SESSION_DRIVER', 'file'),
    'lifetime' => 120,
    'expire_on_close' => false,
    'encrypt' => false,
    'files' => storage_path('framework/sessions'),
    'connection' => null,
    'table' => 'sessions',
    'lottery' => [2, 100],
    'cookie' => 'laravel_session',
    'path' => '/',
    'domain' => null,
    'secure' => false,
];

If anyone has ever been through this or knows anything about it that might help.

Thank you in advance for your attention.

2 answers

0


Fix that bug was just a modification in my controller code modifying the request response View::make for view::make, for some reason the stabbing of View does not add the Cookies in the http request header, I may be mistaken in the use of the stabs, but this solved my case I hope to help others.

0

Log in VerifyCsrfToken.php inside App/HTTP/Middleware and in the array $except add the route in which you do not want to check the token.

protected $except = [
   'route'/
];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.