--- tags: Laravel, livewire, token, lifetime --- # Session lifetime timeout and csrf token mismatch In app/Exceptions/Handler.php replace this: ``` public function render($request, Exception $e) { if ($e instanceof \Illuminate\Session\TokenMismatchException) { return redirect()->back()->withInput()->with('token', csrf_token()); } return parent::render($request, $e); } ``` ``` <div> <script> document.addEventListener('livewire:load', () => { setInterval(function(){ window.livewire.emit('alive'); }, 1800000); }); </script> </div> ```