Search code examples
phplaravelcsrflaravel-5csrf-protection

Laravel 5 csrf_token is mismatch with Session Id


I'm fresh on laravel (5.2).

I try to check the csrf_token() and session::getId().

Both are not same.

What is wrong with that ?

My INPUT :

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

OUTPUT :

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

csrf_token :

 P7EO9KrUgv8JIgGS9WgtvhlBdttkQS7eLPsUTBy4

Session ID :

 89a2f72ff042ab8c644fa651879d4057dafb0bb1 

Solution

  • They're not related.

    The CSRF token is stored inside the session, which is retrieved by the session ID.