V
V
Vladimir2019-05-27 08:29:34
Node.js
Vladimir, 2019-05-27 08:29:34

How to call session anywhere in Express-session script?

This code throws an error

function user(req,res) {
  console.log(req.session.cookie.originalMaxAge + '/' + req.session.id);
};

user();

5ceb759ee28e2572934437.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2019-05-27
@alexeynobody

It also lies in the Request object, you specified them in the declared user method, but did not pass them when calling.
Specifically in the above example, just pass it to your function. But I would think and rewrite it a little differently and just pass the session object, and not the whole Request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question