Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkjs/think-session
Session for ThinkJS 3.x
https://github.com/thinkjs/think-session
session think-extend thinkjs3
Last synced: 2 months 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 (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T15:36:20.000Z (over 3 years ago)
- Last Synced: 2024-10-02T22:37:32.466Z (3 months ago)
- Topics: session, think-extend, thinkjs3
- Language: JavaScript
- Size: 19.5 KB
- Stars: 2
- Watchers: 10
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-session
README
# think-session
[![Build Status](https://img.shields.io/travis/thinkjs/think-session/master.svg?style=flat-square)](https://travis-ci.org/thinkjs/think-session)
[![Coverage Status](https://img.shields.io/coveralls/thinkjs/think-session/master.svg?style=flat-square)](https://coveralls.io/github/thinkjs/think-session?branch=master)
[![npm](https://img.shields.io/npm/v/think-session.svg?colorB=brightgreen&style=flat-square)](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.*