P
P
p3trukh1n2019-06-01 17:55:39
JavaScript
p3trukh1n, 2019-06-01 17:55:39

Why are sessions not saved?

Hello.
I decided to try to add the possibility of authorization in the application through sessions,
but they are not saved.
I'm running it on my local machine ( localhost:3000/).
Code mixed from the official example and other guides:

app.use(session({
  secret: 'some_pass',
  resave: true,
  saveUninitialized: true,
  cookie: { httpOnly: false,
            maxAge  : 24*60*60*1000,
            secure: false,
            resave: false,
            saveUninitialized: true,
            unset: 'destroy',
            domain: 'http://localhost:3000' }
}));
app.get('/', (req, res) => {
  res.json(req.session);
  req.session.test = "1";
})

It is clearly visible. When the page is loaded, the current session is displayed, and a new variable is added to it. However, after reloading the page, it is not visible.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question