Gathering detailed insights and metrics for egg-session
Gathering detailed insights and metrics for egg-session
npm install egg-session
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
49 Stars
34 Commits
9 Forks
9 Watching
2 Branches
23 Contributors
Updated on 02 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-0.4%
3,175
Compared to previous day
Last week
-2.1%
20,545
Compared to previous week
Last month
9.6%
97,590
Compared to previous month
Last year
-58.3%
1,125,355
Compared to previous year
1
Session plugin for egg, based on koa-session.
1npm i egg-session --save
egg-session is a built-in plugin in egg and enabled by default.
1// {app_root}/config/plugin.js 2exports.session = true; // enable by default
egg-session support external store, you can store your sessions in redis, memcached or other databases.
For example, if you want to store session in redis, you must:
1npm i --save egg-redis
1// config/plugin.js 2exports.redis = { 3 enable: true, 4 package: 'egg-redis', 5};
1// config/config.default.js 2exports.redis = { 3 // your redis configurations 4};
1// app.js 2 3module.exports = app => { 4 // set redis session store 5 // session store must have 3 methods 6 // define sessionStore in `app.js` so you can access `app.redis` 7 app.sessionStore = { 8 async get(key) { 9 const res = await app.redis.get(key); 10 if (!res) return null; 11 return JSON.parse(res); 12 }, 13 14 async set(key, value, maxAge) { 15 // maxAge not present means session cookies 16 // we can't exactly know the maxAge and just set an appropriate value like one day 17 if (!maxAge) maxAge = 24 * 60 * 60 * 1000; 18 value = JSON.stringify(value); 19 await app.redis.set(key, value, 'PX', maxAge); 20 }, 21 22 async destroy(key) { 23 await app.redis.del(key); 24 }, 25 }; 26 27 // session store can be a session store class 28 // app.sessionStore = class Store { 29 // constructor(app) { 30 // this.app = app; 31 // } 32 // async get() {} 33 // async set() {} 34 // async destroy() {} 35 // }; 36};
Once you use external session store, session is strong dependent on your external store, you can't access session if your external store is down. Use external session stores only if necessary, avoid use session as a cache, keep session lean and stored by cookie!
Support all configurations in koa-session.
1Support not to print the session value when session event trigger log. Default to be true.
View the default configurations
Please open an issue here.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 18/30 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More