Use of CSRF Token in Laravel

Use of CSRF Token in Laravel

laravel makes it easy to protect your application form csrf attacks.laravel automatically generates csrf token for each active user session managed by the application.This token is used to verify that the authenticated user is the on actually making the requests to the application.

In form we can do CSRF in 2 ways.

1.{{ csrf_field() }}
2.<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">

1st form

<form method = "POST" action="{{url('AddArticle')}}">
{{ csrf_field() }}
...
</form>

2nd Form

<form method = "POST" action="{{url('AddArticle')}}">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
...
</form>