I have a laravel page that allows users to save a search but only if they are logged in. They can log in with no problem or save a search with no problem, the CSRF token is accepted. However, if the user has to log in and then save a search I get the "CSRF token mismatch." error.
I'm assuming that a new token is generated on each post or database update but not sure. Should I be retrieving a new CSRF token after the post to the controller and then updating the CSRF inputs on the page?
I've tried with this in my header
<meta name="csrf-token" content="{{ csrf_token() }}">
and also using this in my forms
@csrf
and then in my ajax calls
var token = $('[name=_token]').val();
The token is being passed in the parameters so I know it is there but will only work on the first ajax call