SessionOptions
Hierarchy
- Omit<CookieSetOptions, maxAge>
- SessionOptions
Index
Properties
optionalContextStore
optionalautoCommit
(boolean) automatically commit headers (default true).
decode
custom decode method
enable
encode
custom encode method
optionalexternalKey
External key is used the cookie by default, but you can use options.externalKey to customize your own external key methods.
genid
The way of generating external session id is controlled by the options.genid, which defaults to Date.now() + "-" + uid.sync(24).
key
cookie key (default is koa:sess)
optionalmaxAge
maxAge in ms (default is 1 days) "session" will result in a cookie that expires when session/browser is closed Warning: If a session cookie is stolen, this cookie will never expire
optionalprefix
If you want to add prefix for all external session id, you can use options.prefix, it will not work if options.genid present.
optionalrenew
Renew session when session is nearly expired, so we can always keep user logged in. (default is false)
optionalrolling
Force a session identifier cookie to be set on every response. The expiration is reset to the original maxAge, resetting the expiration countdown. default is false
Methods
optionalbeforeSave
Hook: before save session
optionalvalid
Hook: valid session value before use it
If your session store requires data or utilities from context, opts.ContextStore is alse supported. ContextStore must be a class which claims three instance methods demonstrated above. new ContextStore(ctx) will be executed on every request.