Answer the question
In order to leave comments, you need to log in
Express-session + socket why doesn't create cookies?
In general, I began to conquer the vastness of nodejs and there was a problem of the following nature!
socket.io + express-session
I go to 127.0.0.1:8080 Cookies are created (connect.id)
I go to site.dev Cookies are not created (connects successfully to the socket)
How can I make sure that cookies are created from site.dev?
var app = require('express')(),
server = require("http").createServer(app),
io = require("socket.io")(server),
session = require("express-session")({
secret: "my-secret",
resave: true,
saveUninitialized: true
}),
sharedsession = require("express-socket.io-session");
app.use(session);
io.use(sharedsession(session));
io.on("connection", function(socket) {
console.log('new');
});
server.listen(8080);
Answer the question
In order to leave comments, you need to log in
Well, put server.listen(80), then the cookie will be placed on port 80.
Why is this happening?
for socket.io, the port is not set and by default it is 80, so io is listening on port 80.
Everything related to sessions revolves around the app and server instance. And you have it on port 8080.
Set port 80 and everything will work on it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question