php - Token mismatch exception only on every first attempt laravel 5.1 -
every time log in application first time after hour or or on every new device token mismatch exception. when try again right after problem goes away. using 755 on storage/framework/sessions -- have same problem on local vagrant scotch box 1.5 box onmy digital ocean lamp. ideas?
the problem csrf token has expired , browser need new token make post request. expiration time default in laravel 2 hours.
i have same problem , trying solution https://laracasts.com/discuss/channels/general-discussion/crsf-checked-before-auth
update:
you need update render method in app/exceptions/handler.php , handle exception: tokenmismatchexception
code example
/** * render exception http response. * * @param \illuminate\http\request $request * @param \exception $e * @return \illuminate\http\response */ public function render($request, exception $e) { if ($e instanceof \illuminate\session\tokenmismatchexception) { return redirect('/')->with('message', 'sorry, session seems have expired. please login again.'); } if ($e instanceof modelnotfoundexception) { $e = new notfoundhttpexception($e->getmessage(), $e); } return parent::render($request, $e); }
Comments
Post a Comment