Skip to content

Recover a session manually when req.session is undefined #99

@tciuro

Description

@tciuro

Hello,

Consider the snippet as shown in the documentation:

app.use(session( /* setup session here */ ))
app.use(function (req, res, next) {
  if (!req.session) {
    return next(new Error('oh no')) // handle error
  }
  next() // otherwise continue
})

When req.session is not available, I ping Redis and it's available. The problem is that the request has already gone through the middleware, so there's no way to recover. Would it be possible to include a function call in connect-redis to allow reloading the session manually? In other words, tell connect-redis to "try again". If we could obtain a session then, we could salvage the situation.

Once I get in this state, connect-redis never recovers. I get a !req.session on every single request... but Redis is working fine (I can access it without problems from terminal). Other than restarting the server (which sucks), is there a way to re-initialize connect-redis so that the next request can be properly initialized with a session?

We're using 1.4.7.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions