1

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 web 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

hretic
  • 999
  • 9
  • 36
  • 78

2 Answers2

0

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.

Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • i want to use session , session start is in web middleware apparently – hretic Oct 24 '16 at 14:38
  • @hretic, yes, you'll be able to use sessions after you remove web middleware since it applies automatically. – Alexey Mezenin Oct 24 '16 at 14:39
  • 1
    thanx it worked , funny thing i had problem with getting my session to work and i red somewhere since 5.2 i should use web middleware to solve it ... and there goes 1 hour of my time ! – hretic Oct 24 '16 at 14:48
0

If the form is not token field _token

<form method="POST" action="">
    {{ csrf_field() }}
    ...
</form>
Ilya Yaremchuk
  • 2,007
  • 2
  • 19
  • 36