Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Life of a User Session

The Life of a User Session

Session Management is one of the many uses cases for Redis, but what do we really mean when we say Redis can be used as a session store? We’ll start with an overview of what sessions are in the context of web applications and cover some common use cases. Then we’ll look at the process of adding session management to a Node.js application using Redis as the session store. With basic session management in place, we’ll then explore options for situations where you may want to store session data after a session has ended.

Redis Day NYC 2019

Jan Kleinert

June 27, 2019
Tweet

More Decks by Jan Kleinert

Other Decks in Technology

Transcript

  1. PRESENTED BY 1 What are sessions? 2 Adding session management

    to a web app 3 What comes next? Agenda:
  2. PRESENTED BY express-session + connect-redis app.use(session({ genid: (req) => {

    return uuid() }, store: new redisStore({ host: 'localhost', port: 6379, client: redisClient }), name: '_redisDemo', secret: process.env.SESSION_SECRET, resave: false, cookie: { secure: false, maxAge: 60000 }, // Set to expire in 1 minute for demo purposes saveUninitialized: true }))
  3. PRESENTED BY You can use Redis as a cache and

    a session store! https://redislabs.com/blog/cache-vs-session-store/
  4. PRESENTED BY Example repo: https://github.com/jankleinert/redis-session-demo Modules used in these examples:

    • express-session: https://www.npmjs.com/package/express-session • connect-redis: https://www.npmjs.com/package/connect-redis • uuid: https://www.npmjs.com/package/uuid • passport: https://www.npmjs.com/package/passport Cache vs. Session Store blog: https://redislabs.com/blog/cache-vs-session-store/ Redis Enterprise Operator: https://github.com/RedisLabs/redis-enterprise-k8s-docs Try the operator mini-lab: http://bit.ly/2NgxBaK Find me on Twitter/Github: jankleinert Resources