sessionexpressexpress-sessionsession-store

How to use redis store in express session using connect-redis?


I am trying to look for a tutorial that explains your how to setup user session in redis store using express session. I know how to set it up, but I could not find out how to access redis store and how to store and retrieve values from that redis store?


Solution

  • I'm assuming you want to store and read values from the session (using the express-session module) and not use redis directly. For this you'll want to use the req.session object in a request.

    Checkout the functions here in the documentation - https://github.com/expressjs/session#reqsession

    If you're trying to store some values directly into redis (perhaps using redis for multiple things) then checkout https://www.npmjs.com/package/redis