https://github.com/thinkjs/think-session
Session for ThinkJS 3.x
https://github.com/thinkjs/think-session
session think-extend thinkjs3
Last synced: 12 days ago
JSON representation
Session for ThinkJS 3.x
- Host: GitHub
- URL: https://github.com/thinkjs/think-session
- Owner: thinkjs
- License: mit
- Created: 2017-03-16T03:08:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T15:36:20.000Z (almost 4 years ago)
- Last Synced: 2025-03-22T04:01:51.722Z (28 days ago)
- Topics: session, think-extend, thinkjs3
- Language: JavaScript
- Size: 19.5 KB
- Stars: 2
- Watchers: 9
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-session
README
# think-session
[](https://travis-ci.org/thinkjs/think-session)
[](https://coveralls.io/github/thinkjs/think-session?branch=master)
[](https://www.npmjs.com/package/think-session)Session for ThinkJS 3.x.
Add `session` method for controller/context.
## config
config file `src/config/adapter.js`, add options:
```js
const cookie = require('think-session-cookie');
exports.session = {
type: 'cookie',
common: {
maxAge: 24 * 3600 * 1000, // 1 day
},
cookie: {
handle: cookie
}
}
```## session method
* `this.session()` get all session data
* `this.session(name)` get session data with name
* `this.session(name, value)` set session data
* `this.session(null)` delete all session data
* `this.session(name, undefined, options)` get session data with options*For each `ctx`, session is only instantiated once.*