I have an app. When the user goes to the home page of the application, a new session is created with the ID, and never expires, I checked how my application works on the local computer, and everything works as it should, after going to the main page of the application, a session with the id is created and never expires.
But when I run this app in glitch, it doesn’t work correctly, session of my nodejs app is expiring every time I refresh the page. Each time the page is reloaded, a new session is created with a new ID. Here is my code:
app.set('trust proxy', 1);
app.use(session({
cookie: {
httpOnly: true,
sameSite: true,
secure: true
},
resave: false,
saveUninitialized: true,
store: new MongoStore({mongooseConnection: db}),
secret: process.env.secret,
name: 'ses'
}));
mainRoute:
app.get('/', (req, res)=>{
res.sendFile(__dirname+'/public/index.html');
req.session.a = "some data";
});
Sorry for my English. I will be glad if someone helps !!