hretic hretic - 9 months ago 60
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


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.