With each ajax request, a new session is created on the server (in the storage/sessions/ folder)
I am writing a token to the session, then I insert it like this<meta name="csrf" content="<?= $_getToken ?>">
so that js could pull it out and send ajax request om '
That's how I pull and send token
let formData = new FormData(); formData.append('_token', document.querySelector('#csrf').content) fetch('/cart/add', { method: 'POST', headers: { PHPSESSID: token }, body: formData }) .then(function (response) { return response.json() }).then(function (json) { console.log('parsed json', json) }).catch(function (ex) { console.log('parsing failed', ex) }) Class session
Class FileSessionHandler
credentials: 'include'to the fetch parameters? - andreymal