Answer the question
In order to leave comments, you need to log in
Why doesn't unload work?
I'm trying to close the session before exiting the tab with this code
window.unload = function() {
let xhr = new XMLHttpRequest();
xhr.open('GET', '/user/sessionDestroy');
xhr.send();
};
router.get('/sessionDestroy', (req, res) => {
console.log(1);
req.session.destroy();
res.status(200).send('ok');
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question