socket下修改session的问题
//session相关设置
var Session = require('express-session');
var MemoryStore = Session.MemoryStore;
var sessionStore = new MemoryStore();
app.use(Session({ secret: 'ta_shuo_session',
key: 'express.sid' ,
cookie: { maxAge: 60000},
store: sessionStore,
resave: true,
saveUninitialized: true
}));
...
io.set('authorization', function (handshakeData, accept) {
...
}
io.on('connection', function(socket){
var cookie_t = cookie.parse(socket.handshake.headers.cookie);
var session_id = cookieParser.signedCookie(cookie_t['express.sid'], 'ta_shuo_session');
socket.emit('connect');
socket.on('test', function(data){
//***这里有办法操作 sessionStore 来修改session值吗***
});
如上,怎么在socket事件中修改session,session存储于mc中
2 回复
顶一下…不要沉
只能手动去修改数据库了,或者你写一个 socket 连接的session中间件