Search code examples
phplaravellaravel-5csrf-protection

laravel 5 csrf_token value is Empty


Why laravel 5 csrf_token value is empty always ?

How can i get that token value ?

I tried,

  {!! csrf_token !!} , {{ csrf_token }} and 
  {{ Form::open() }} ....{{ Form::close() }}

MY OUTPUT

  <input type="hidden" name="_token"></input>

Solution

  • It's because you're not using the web group middleware. Laravel is smart enough to know that if you're not using that group a token is not necessary.

    Try moving your route inside the Route::group(['middleware' => 'web'] ... and tell us about it :)

    Source: I made the same mistake not too long ago.