{"name":"@eggjs/session","version":"5.0.2-beta.17","keywords":["cookie","egg","egg-plugin","eggPlugin","session"],"author":{"name":"dead_horse"},"license":"MIT","_id":"@eggjs/session@5.0.2-beta.17","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"644171127@qq.com"},{"name":"niania","email":"ljracm@gmail.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/plugins/session#readme","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"adbcdae76fd2f331141aee0b225ab984d85c94c0","tarball":"http://registry-npm.ywwl.com/@eggjs/session/download/@eggjs/session-5.0.2-beta.17.tgz","fileCount":15,"integrity":"sha512-oqlbzlfrCSfsMSJwoyE5XFgVG7KBCj9tzd9lp1NDYwa3ncJuQe4TXBpV9HOkInhBv/NiV74EiYwT2uPHBocqRw==","signatures":[{"sig":"MEYCIQDMlu8FDKK4qqyESzg7y0emPZXsO16iZZK69ihRfdUCcwIhAKFw0JCMqkw82BiuWBykUh8AV9ZLLWpVE/6dph4TDm8b","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fsession@5.0.2-beta.17","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12006,"size":4427,"noattachment":false,"key":"/@eggjs/session/-/@eggjs/session-5.0.2-beta.17.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-session-5.0.2-beta.17.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">= 22.18.0"},"exports":{".":"./dist/index.js","./app":"./dist/app.js","./types":"./dist/types.js","./package.json":"./package.json","./config/config.default":"./dist/config/config.default.js","./app/extend/application":"./dist/app/extend/application.js","./app/middleware/session":"./dist/app/middleware/session.js"},"scripts":{"typecheck":"tsgo --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:1500a3c4-3085-4b44-b062-17ba4eb49acd"}},"_resolved":"/tmp/c5d409a2f4ac9811eff4bcdf671d891b/eggjs-session-5.0.2-beta.17.tgz","_integrity":"sha512-oqlbzlfrCSfsMSJwoyE5XFgVG7KBCj9tzd9lp1NDYwa3ncJuQe4TXBpV9HOkInhBv/NiV74EiYwT2uPHBocqRw==","repository":{"url":"git+https://github.com/eggjs/egg.git","type":"git","directory":"plugins/session"},"_npmVersion":"11.13.0","description":"session plugin for egg","directories":{},"_nodeVersion":"24.17.0","dependencies":{"zod":"^3.24.1","koa-session":"^7.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"egg":"4.1.2-beta.17","typescript":"^5.9.3","@eggjs/mock":"7.0.2-beta.17","@types/node":"^24.10.2","@eggjs/redis":"4.0.2-beta.17","@eggjs/supertest":"9.0.2-beta.17"},"peerDependencies":{"egg":"4.1.2-beta.17"},"_npmOperationalInternal":{"tmp":"tmp/session_5.0.2-beta.17_1782607381853_0.3799148518471389","host":"s3://npm-registry-packages-npm-production"},"readme":"# @eggjs/session\n\n[![NPM version][npm-image]][npm-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[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## Usage\n\n`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/egg/tree/next/plugins/redis)\n\n```bash\nnpm i --save @eggjs/redis\n```\n\n2. Import `@eggjs/redis` as a plugin and set the configuration\n\n```js\n// config/plugin.js\nexports.redis = {\n  enable: true,\n  package: '@eggjs/redis',\n};\n```\n\n```js\n// config/config.default.js\nexports.redis = {\n  // your redis configurations\n};\n```\n\n3. Implement a session store with redis\n\n```js\n// app.js\n\nmodule.exports = (app) => {\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/tree/next/plugins/session/src/config/config.default.ts)\n\n## Questions & 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/egg)](https://github.com/eggjs/egg/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1782607381988,"_cnpm_publish_time":1782607381988,"dist-tags":{"beta":"5.0.2-beta.27","latest":"5.1.0","rc":"5.0.2-rc.1"}}