hretic hretic - 1 year ago 108
PHP Question

TokenMismatchException after using web middleware

im adding csrf_field to all my forms by default and it was working fine , i decided to store some data in session so i've grouped some routes and used

middlewar on them

Route::group(['middleware' => ['category' , 'web']], function () {
Route::get('/', 'HomeController@index');
Route::get('/dashboard', 'DashboardController@index')->name('dashboard');

now when i submit a form i get this error

TokenMismatchException in VerifyCsrfToken.php line 67:

but they work fine if i remove web middleware !!

im using database drive for my sessions ... i dont know if that's relevant

Answer Source

Remove web middleware, that should fix the problem.

Since 5.2.27 web middleware applies automatically to all routes (in 5.3 to all routes in routes/web.php) and you shouldn't add it manually.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download