I have a nodejs app set up with express and mongodb. The app has a login area and I'm using express sessions with mongodb to save logged in session so that if a user didn't log out from the account I could keep them logged in when they visit the site next time. Same user could have one or more logged sessions in different computers or browsers on the same computer.
I'm having trouble with deleting sessions of the same user. I want to delete the other session of the same user when a user makes an update to member information like upload a new profile image.
Ended up doing the followings(until come up with a better solution):
Loop though each session
i. Convert the session string to JSON
ii. Compare the sessionIDs, if not the current sessionID remove the document from the mongodb or continue to the next one
Update the current session