0
I’m having a problem, sharing the Express cookie user data and session functions! the goal is to store such data in my Socket.IO, but it presents a reference error problem where it says the session is not set. I have little knowledge about it, I would like to know how and where I will name this session?
Excerpt from the code where the error points : const currentSession = Session[sessionid]
//Verificado de regra
io.use((socket,next) =>{
const cookieData = socket.request.headers.cookie;
const cookieObj = cookie.parse(cookieData);//Gera um objeto com dados do cookie
const sessionHash = cookieObj[config.sessionKey] ||'';// Acessa o hash da sessão
const sessionID = sessionHash.split('.')[0].slice(2);
store.all((err,sessions)=>{
const currentSession = session[sessionID]; // referenciar a sessão ID
if( err|| !currentSession){
return next(new Error('Acesso Negado!'));
}
socket.handshake.session = currentSession;
return next();
})
})
My God! What a shame, that was it kkkkkkk Sorry, it was worth obg!
– Isaac Bandim