我已经导入了cookie-parser模块了:
1 回答
慕姐8265434
TA贡献1813条经验 获得超2个赞
// 设置socket的session验证
io.use(function (socket, next) {
if (socket.request.headers.cookie) {
socket.request.cookies = cookie.parse(socket.request.headers.cookie);
next();
} else {
return next(new Error('Missing cookie headers'));
}
});
io.on('connection', function (socket) {
console.log(socket.request.cookies);
});
添加回答
举报
0/150
提交
取消