How To Avoid TokenMismatchException On Logout

  • Many time we faced TokenMismatchException error in laravel, this error occurred If you stay too long time on one form or if your system stay on idle or you are not active on your computer, and then again try to fill this form.
  • At that time you may get a TokenMismatchException error, because the CSRF token won’t be the same. recently many time we found this problems in logout time. So, In this example i will show you to how to avoid it.
  • Normally, if you are not active for long time in your system then you will get this error.
  • To avoid TokenMismatchException error, we may add exceptions for the URLs that we don’t want to have CSRF protection. There are special array for that in app/Http/Middleware/VerifyCsrfToken.php
class VerifyCsrfToken extends Middleware
* The URIs that should be excluded from CSRF verification.
@var array
protected $except = [
protected $except = [



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API. Visit Website: