How to save and retrieve session from Redis

前端 未结 3 1611
无人及你
无人及你 2020-12-07 17:57

I am trying to integrate Redis sessions into my authentication system written in Node.js.

I have been able to successfully set up Redis server, connect-redis

3条回答
  •  自闭症患者
    2020-12-07 18:10

    That should be all there is to it. You access the session in your route handlers via req.session. The sessions are created, saved, and destroyed automatically.

    If you need to manually create a new session for a user, call req.session.regenerate().

    If you need to save it manually, you can call req.session.save().

    If you need to destroy it manually, you can call req.session.destroy().

    See the Connect documentation for the full list of methods and properties.

提交回复
热议问题