php - how to manage a special error with special message in laravel -
i'm using laravel 5.4. , need handle error. imagine user logged in , opened 2 windows (his profile). when user click on logout in window, have still logout button in window, , clicking on that, laravel show csrf_token error page.
my logout in not ajax , submitting form /logout
how can handle error special message or redirect home without error logout controller? (not of csrf_token
errors, controller).
logout form :
i submit form clicking on logout button using jquery:
<form id="logout-form" action="/logout" method="post" style="display: none;"> <input type="hidden" name="_token" :value="token"> </form>
and logout method in controller :
public function logout(request $request) { $this->guard()->logout(); $request->session()->flush(); $request->session()->regenerate(); return redirect('/'); }
in app\exceptions\handler.php return user form new valid csrf token, page refreshed , logout button not exist.
public function render($request, exception $exception) { if($exception instanceof tokenmismatchexception) { return redirect() ->back() ->with('your msg'); } return parent::render($request, $exception); }
this looking like, page refreshed.
don't replace post get. not safe , standard.
Comments
Post a Comment