koajs / session

Simple session middleware for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ctx.session = null; ctx.session.manuallyCommit` works, but is confusing

vjpr opened this issue · comments

// ctx.session is a setter that calls `ContextSession#set`.
// NOTE: This is why we can make it null, but then still use it.
// ContextSession#set. It checks for `null`, and sets `ContextSession.session = false`.
ctx.session = null
// Commit will delete cookie (i.e set-cookie: '' in response) if `ContextSession.session === false`
await ctx.session.manuallyCommit()

The docs say to set ctx.session = null to clear the session.

ctx.session is a getter calling ContextSession#set.

Its confusing to be able to set it to null, then call methods on it.

Nope, I was wrong. Bug was different. See #153.