I'm using Express cookie-session for authentication, which, if I understand correctly, works by storing a cookie locally in the browser of the user and no session data client-side.
The documentation says that in order to logout we should set req.session = null
on the server. So right now, my client does an HTTP request to that endpoint.
Client:
async function logout() {
await fetch(
process.env.REACT_APP_SERVER_URL + "/logout",
{
method: "POST",
}
)
}
Server:
exports.logout = (req, res, next) => {
req.session = null
res.sendStatus(200)
}
But this can obviously fail if the server is down. So now I'm wondering if it's enough to just delete the session cookie client-side and even remove the logout endpoint completely. If there is no session data stored on the server, this should work just as well and not leave any residue, right?