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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -