2

Is there a real difference between csrf_token()

<input type="hidden" name="_token" value="{{ csrf_token() }}"/>

and Session::token() ?

<input type="hidden" name="_token" value="{{ Session::token() }}" />

They both seem to produce the same result.

Peon
  • 7,902
  • 7
  • 59
  • 100

1 Answers1

3

Laravel provides a variety of different methods for performing the same tasks.

The first example is a helper function: https://laravel.com/docs/5.1/helpers

The second example is the Session facade: https://laravel.com/docs/5.1/facades

There is no difference in the result as they will both call the same method in the end. The actual method they are calling is: https://laravel.com/api/5.1/Illuminate/Session/Store.html#method_token

Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95