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.

CSRF Token can easily use in Laravel 7, Laravel 6, Laravel 5.8, Laravel 5.7, Laravel 5.6, Laravel 5.5, Laravel 5.4 OR etc………….

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>