{"id":13487456,"url":"https://github.com/eggjs/session","last_synced_at":"2026-01-23T18:16:09.440Z","repository":{"id":53578662,"uuid":"63323444","full_name":"eggjs/session","owner":"eggjs","description":"session plugin for egg","archived":false,"fork":false,"pushed_at":"2025-01-21T16:43:26.000Z","size":64,"stargazers_count":49,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-12-03T15:30:01.633Z","etag":null,"topics":["egg","egg-plugin","egg-session","session"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eggjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-07-14T09:40:54.000Z","updated_at":"2025-01-21T16:43:28.000Z","dependencies_parsed_at":"2024-11-06T08:02:32.536Z","dependency_job_id":"556c5642-413d-419f-87de-c29f224117d0","html_url":"https://github.com/eggjs/session","commit_stats":{"total_commits":34,"total_committers":9,"mean_commits":"3.7777777777777777","dds":0.5588235294117647,"last_synced_commit":"0f06e001fb9bbb955d37cb3e0ebfc35976b0125f"},"previous_names":["eggjs/session"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/eggjs/session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fsession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fsession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fsession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fsession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eggjs","download_url":"https://codeload.github.com/eggjs/session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fsession/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28697428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["egg","egg-plugin","egg-session","session"],"created_at":"2024-07-31T18:00:59.624Z","updated_at":"2026-01-23T18:16:09.407Z","avatar_url":"https://github.com/eggjs.png","language":"TypeScript","readme":"# @eggjs/session\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/eggjs/session/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/session/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/session.svg?style=flat)](https://nodejs.org/en/download/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)\n![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/session)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/session.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/session\n[codecov-image]: https://codecov.io/gh/eggjs/session/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/eggjs/session\n[snyk-image]: https://snyk.io/test/npm/@eggjs/session/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/session\n[download-image]: https://img.shields.io/npm/dm/@eggjs/session.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/session\n\nSession plugin for egg, based on [koa-session](https://github.com/koajs/session).\n\n## Install\n\n```bash\nnpm i @eggjs/session\n```\n\n## Usage\n\negg-session is a built-in plugin in egg and enabled by default.\n\n```js\n// {app_root}/config/plugin.js\nexports.session = true; // enable by default\n```\n\n### External Store\n\negg-session support external store, you can store your sessions in redis, memcached or other databases.\n\nFor example, if you want to store session in redis, you must:\n\n1. Dependent [@eggjs/redis](https://github.com/eggjs/redis)\n\n  ```bash\n  npm i --save @eggjs/redis\n  ```\n\n2. Import `@eggjs/redis` as a plugin and set the configuration\n\n  ```js\n  // config/plugin.js\n  exports.redis = {\n    enable: true,\n    package: '@eggjs/redis',\n  };\n  ```\n\n  ```js\n  // config/config.default.js\n  exports.redis = {\n    // your redis configurations\n  };\n  ```\n\n3. Implement a session store with redis\n\n  ```js\n  // app.js\n\n  module.exports = app =\u003e {\n    // set redis session store\n    // session store must have 3 methods\n    // define sessionStore in `app.js` so you can access `app.redis`\n    app.sessionStore = {\n      async get(key) {\n        const res = await app.redis.get(key);\n        if (!res) return null;\n        return JSON.parse(res);\n      },\n\n      async set(key, value, maxAge) {\n        // maxAge not present means session cookies\n        // we can't exactly know the maxAge and just set an appropriate value like one day\n        if (!maxAge) maxAge = 24 * 60 * 60 * 1000;\n        value = JSON.stringify(value);\n        await app.redis.set(key, value, 'PX', maxAge);\n      },\n\n      async destroy(key) {\n        await app.redis.del(key);\n      },\n    };\n\n    // session store can be a session store class\n    // app.sessionStore = class Store {\n    //   constructor(app) {\n    //     this.app = app;\n    //   }\n    //   async get() {}\n    //   async set() {}\n    //   async destroy() {}\n    // };\n  };\n  ```\n\nOnce 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!**\n\n## Configuration\n\nSupport all configurations in [koa-session](https://github.com/koajs/session).\n\n* logValue\n\n```bash\nSupport not to print the session value when session event trigger log. Default to be true.\n```\n\n[View the default configurations](https://github.com/eggjs/egg-session/blob/master/config/config.default.js)\n\n## Questions \u0026 Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/session)](https://github.com/eggjs/session/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","funding_links":[],"categories":["仓库"],"sub_categories":["[内置插件](https://eggjs.org/zh-cn/basics/plugin.html#%E6%8F%92%E4%BB%B6%E5%88%97%E8%A1%A8)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fsession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggjs%2Fsession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fsession/lists"}