会话在mongodb存储。 当用户访问网站时。但我无法获得会话值
var cookieParser=require("cookie-parser");
var signedCookieParser=cookieParser("technode");
var sessionStore=new MongoStore({url:"mongodb://localhost/technode"});
io.set('authorization', function(handshakeData, accept) {
//console.log(handshakeData.headers);
signedCookieParser(handshakeData, {}, function(err) {
if (err) {
accept(err, false)
} else {
sessionStore.get(handshakeData.signedCookies['connect.sid'], function(err, session) {
if (err) {
accept(err.message, false)
} else {
handshakeData.session = session;
console.log(handshakeData.session); //But I can't get the value
if (session) {
accept(null, true)
} else {
accept('No login')
}
}
})
}
})
accept(null,true);
})
我想打印handshakeData.session.But它转向" undefined"