So what I'm trying to do is when the users accesses the page it will fetch their user profile from the mongodb database and then update the users session with the users profile.
Right now I'm currently using the following packages for sessions:
- express-socket.io-session (allows me to access cookies through socket.io)
- express-session
- connect-mongo (Allows me to store sessions in a mongodb database)
Heres what I've tried to use to get the users cookies to update
req.session.reload(function(err) {
// session updated
})
Typically you save object (e.g user profile) in session and session is stored in mongo.
Cookie on client contains only expires date and session id. With each request you get cookie with session ID and can obtain session from mongo by this ID.
When you update any field in session it will be resaved in mongo.
So you don't need 'reload'. You can just assign in like
req.session.user = user
.Docs