What is the maximum time of the session at express-session?



  • We all know that it is possible to limit the time of the session to the life of a bitch as described in the documentation express-session:

    session.cookie.maxAge
    

    On the face, the effect of the session is, but if you look at it, req.sessionStore.sessions - you'll see that there's still all the sessions that are going to die! The question is, sessionStore Ooh. express-session ever clean up? Can I get him some cleaning time? As long as you haven't found that kind of infusion, you're gonna say you can write some of your crutch that cleans up. sessionStorebut can there still be something to build a built-in function? And if you write your crutch, how do you know that the session has already died?

    Well, it's interesting to know who's gonna say something. ♪ ♪



  • 1.a. If inMemmory repository is used (and is used in default if not otherwise specified), the sessions shall not be removed from memory, which is correctly written in the logs when the annex is launched. The codes can be written, but it's best to get used at once by using a different inMemory vault, because you're not allowed to scale up, and if it's re-launched, all users will remember you with a bad word.

    1.B. Other vaults have their clean-up mechanism, and the specification is better off.

    1. The time of the session can be asked through the options transmitted at the initialization of the repository.

    //это подключение хранилища
    app.use(session({
      secret: 'keyboard cat',
      cookie: {
        maxAge: 24*60*60*1000 //вот в этом объекте задается время жизни сессии
      }
    }))

    All the details are in. https://github.com/expressjs/session#cookie-options




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2