Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,003 members, 7,956,719 topics. Date: Monday, 23 September 2024 at 05:25 PM |
Nairaland Forum / Science/Technology / Programming / Solution To Tokenmismatchexception Problem In Laravel 5.1 (5636 Views)
How To Create Multiple User Authentication In Laravel 5.3 / Common Error In Laravel #1:solved File_put_contents Failed To Open Stream / Create A Nested Lists Of Categories In Laravel 5 (2) (3) (4)
(1) (Reply)
Solution To Tokenmismatchexception Problem In Laravel 5.1 by dplumptre(m): 2:22pm On Sep 14, 2015 |
Hello peeps , I dont know if you have notice this error "TokenMismatchException in VerifyCsrfToken.php line 53" sometimes when you are trying to login , it looks alot like the image below see images below Laravel provides an easy method of protecting your application from cross-site request forgeries, it uses CSRF Protection and its can be done by using form helper in your application like this below {!! Form::open() !!} {!! Form::close() !!} From laravel 5 , the form helper has been yanked off , but you can always easily integrate it to your laravel 5.1 application I will cover that in a latter tutorial, The solution to this error is just navigating to your auth/logout page so it will just destroy the session and login from the login page again. But if you where designing application for users , you wont want them to see the hideous error page or even if you have a good error page you still need to find a way to solve the issue for them. Here is what you do Create tokenerror_page.blade.php error page that will navigate people to where the will logout from the auth/logout page the route may look like this below Route::get('/token_error_page', function () { see image below Then you navigate to app/Exceptions/Handler.php in the render method just include this if($e instanceof \Illuminate\Session\TokenMismatchException) this will catch the exception and navigate to the error page that you have created and they can click on the login from here button and this time your users will be able to signin without no errors if you want to see more stuffs visit my blog http://overallheuristic.com/blog/ site : http://overallheuristic.com twitter : @dplumptre fb :https://www.facebook.com/
|
Re: Solution To Tokenmismatchexception Problem In Laravel 5.1 by dplumptre(m): 9:54am On Oct 12, 2015 |
if you dont want to create any fancy page , you could just redirect to the logout page navigate to app/Exceptions/Handler.php in the render method just include this if($e instanceof \Illuminate\Session\TokenMismatchException) { return redirect('/auth/logout'); //so it kills the session and takes you where you wil login easily } |
(1) (Reply)
Dll Load Failure With Py2exe (python And Qt) / Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) / How Can I Build A Loan App Of Mine Own
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |