Laravel 5.1 problems with csrf_token

0

I have a problem in my site made in laravel, the following happens my application in laravel is not returning the Session Token that would be {{ csrf_token() }} when I perform an action like registering or logging the same I return the following error:

Thiserrorhappensonlyontheproductionserver,tryingtosolveitIendedupidentifyingthatwhenIamaccessingthesiteontheproductionservertheclientdoesnotreceivethesessiontokenthatshouldbeincookiesasintheimagesbelow:

SessionTokeninDevelopment: Sessionsessiontoken: As it turned out, it is as if the application does not return the session token on the production server, even though a token is sent in the request that is different from the one generated by the application and generates the error I reported above.

Below my session settings in the .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 someone has already experienced this or knows something about it that can help.

Thank you in advance for your attention.

    
asked by anonymous 17.05.2017 / 14:40

2 answers

0

Correction of this bug was only a modification in the code of my controller modifying the response of the View::make request to view::make , for some reason the View facade does not add the Cookies in the HTTP request header, I can be wrong in using the facades, but this solved my case I hope to help others.

    
25.05.2017 / 21:48
0

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

protected $except = [
   'route'/
];
    
25.05.2017 / 21:53