diff --git a/index.js b/index.js index 7156fcb..03ac9eb 100644 --- a/index.js +++ b/index.js @@ -80,18 +80,17 @@ export default class Controller { // 会话读写 session(key, val) { - let { enabled } = this.context.get('session') let { ssid } = this.request - if (enabled) { + if (this.context.$$session) { + key += '' + if (arguments.length < 2) { // 这里返回的是Promise对象 return this.context.$$session.get(ssid, key) } - - key += '' this.context.$$session.set(ssid, key, val) } else { - throw Error('Session was disabled.') + throw new Error('Session was disabled.') } } }