chill117 / express-mysql-session

A MySQL session store for the express framework in node
MIT License
313 stars 108 forks source link

Delete record from table when user log out? #122

Closed BadPistol97 closed 1 year ago

BadPistol97 commented 3 years ago

How to delete the record in the table when user log out? if I am supposed to do so.

antefix-consulting commented 3 years ago

I was wondering that the other day. If I read the source code correctly, expired session records are deleted automatically every fifteen minutes, so you do not need to delete them yourself.

chill117 commented 3 years ago

In your application logic, you can delete the session of the active user when they logout. The express-session module adds the session ID to the request object of express as req.session.id. So in your logout route, you could delete the session row from your database using this session ID.

chill117 commented 1 year ago

Closing this as it's likely been solved.