connect-redis-crypto provides Redis session storage for Express. Requires Redis >=
Migrating to V4? See this guide on what's changed.
npm install redis connect-redis-crypto express-session
yarn add redis connect-redis-crypto express-session
const redis =const session =let RedisStore = sessionlet redisClient = redisapp
RedisStore requires an existing Redis client. Any clients compatible with the
redis API will work. See
client option for more details.
An instance of
redis or a
redis compatible client.
Known compatible and tested clients:
Key prefix in Redis (default:
This prefix appends to whatever prefix you may have set on the
Note: You may need unique prefixes for different applications sharing the same Redis instance. This limits bulk commands exposed in
clear) to a single application's data.
If the session cookie has a
connect-redis will use it as the TTL.
Otherwise, it will expire the session using the
ttl option (default:
86400 seconds or one day).
Note: The TTL is reset every time a user interacts with the server. You can disable this behavior in some instances by using
express-session does not update
expires until the end of the request life cycle. Calling
session.save() manually beforehand will have the previous value.
Disables re-saving and resetting the TTL when using
express-session package uses
touch to signal to the store that the user has interacted with the session but hasn't changed anything in its data. Typically, this helps keep the users session alive if session changes are infrequent but you may want to disable it to cut down the extra calls or to prevent users from keeping sessions open too long. Also consider enabling if you store a lot of data on the session.
The encoder/decoder to use when storing and retrieving session data from Redis (default:
Value used for count parameter in Redis
SCAN command. Used for
all() methods (default:
How to log Redis errors?
How do I handle lost connections to Redis?
If you want to retry, here is another option.