node.js - nodejs & express delete session from sessionStore -
i need check whether user has logged in pc , if terminate previous session.
the following code not throw errors when executes, unable end first session either calling destroy() on session store or deleting session id session store using delete.
how can terminate session of user using session id ?
function test(user_id){ var ss = sessionstore.sessions; for(var sid in ss){ var ses = json.parse(ss[sid]); if(ses.user_id==user_id) { console.log('kill:'+sid) delete ss[sid]; sessionstore.destroy(sid,function(x){}); } } }
try this:
req.session.destroy();
this works in 4.x express.
so in case ss[sid].destroy();
Comments
Post a Comment