https://github.com/bin-huang/koa-redis-session
Simple redis session store for `koa-session`
https://github.com/bin-huang/koa-redis-session
Last synced: 6 months ago
JSON representation
Simple redis session store for `koa-session`
- Host: GitHub
- URL: https://github.com/bin-huang/koa-redis-session
- Owner: Bin-Huang
- Created: 2018-02-01T06:51:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T07:23:47.000Z (over 7 years ago)
- Last Synced: 2025-02-13T20:24:37.768Z (8 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple redis sessioin store for [koa-sessioin](https://github.com/koajs/session).
```javascript
const session = require("koa-session");
const redisStore = require("koa-redis-session");
const Koa = require("koa");
const app = new Koa();app.keys = ["some secret hurr"];
app.use(session({
key: 'koa:sess',
maxAge: 86400000,store: new redisStore({
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
family: 4, // 4 (IPv4) or 6 (IPv6)
password: 'auth',
db: 0,
// ... And more options you can use in ioredis
// See: https://github.com/luin/ioredis/blob/HEAD/API.md#new_RedisonError: (e) => console.log(e), // Optional. it will be called when redis client emits an error event.
}),
}, app));
```# Why Use?
When you use `koa-session` without external session stores, the session is stored in a cookie by default. It has some disadvantages:
- Session is stored on client side unencrypted
- Browser cookies always have length limitsIf you every care about one of the above in your project, you should use an external session store.
In addition, when you use external stores, session storage is dependent on your external store -- you can't access the session if your external store is down. Use external session stores only if necessary.
refer: https://github.com/koajs/session