Skip to content

Use Redis store session for ThinkJS 3.x

License

Notifications You must be signed in to change notification settings

thinkjs/think-session-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

think-session-redis

Use Redis to store session for ThinkJS

Build Status Coverage Status npm

Install

npm install think-session-redis

How to use

config file src/config/adapter.js, add options:

const redisSession = require('think-session-redis');
exports.session = {
  type: 'redis',
  common: {
    cookie: {
      name: 'thinkjs',
      //maxAge: '',
      //expires: '',
      path: '/',  //a string indicating the path of the cookie
      //domain: '',
      //secure: false,
      //keys: [],
      httpOnly: true,
      sameSite: false,
      signed: false,
      overwrite: false
    }
  },
  redis: {
    handle: redisSession,
    maxAge: 3600 * 1000, //session timeout, if not set, session will be persistent.
    autoUpdate: false, //update expired time when get session, default is false
  }
}