-
-
Save ManojKiranA/4f7bf9d65dabba2fcef2d3c510ea50ff to your computer and use it in GitHub Desktop.
Keep livewire form session alive (419)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script data-turbolinks-eval=false> | |
function updateToken() { | |
fetch('/update-csrf') | |
.then(response => response.text()) | |
.then(csrf => { | |
document.head.querySelector('meta[name="csrf-token"]').setAttribute('content', csrf) | |
}) | |
} | |
setInterval(updateToken, 1000 * 60 * 5) | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('update-csrf', fn () => response(csrf_token()))->middleware('auth'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment