php - How do I prevent the mismatch token error in laravel? -


i started using laravel , it's great. lot of useful functionality etc. have problem csrf_token. session time default 120 minutes , let's log in, , browser tab stays open without me doing 120 minutes , expires, meaning have log in again. when on page after 120 minutes of inactivity, requires user authenticated, using post method, mismatch token exception error. need solve because indeed possibility user leave browser tab open without doing anything. know how solve this?

in app/exceptions/handle.php, replace render function 1 :

public function render($request, exception $e) {      if ($exception instanceof \illuminate\session\tokenmismatchexception) {             return redirect()             ->back()             ->withinput($request->except('password', '_token'))             ->witherror('validation token has expired. please try again');      }     return parent::render($request, $e); } 

it redirect same page new token.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -