Documentation / zerotal / contracts / SessionContract
Interface: SessionContract
Defined in: packages/core/src/contracts/session.ts:18
The session contract — the interface the kernel consumes so that
HttpContext.flash() / flashed() and any session-aware code depend on a
shape, never on @zerotal/session.
@zerotal/session provides the implementation (SessionManager is what
lands on ctx.session; SessionAccessor backs the Session facade). A third
party can ship an alternative store and satisfy the same contract, and core is
none the wiser.
Remarks
This file has zero runtime code and imports nothing — it is pure type surface. The extension point is an interface the compiler enforces, so a miswired implementation is a build error rather than a runtime surprise.
Methods
id()
id():
string
Defined in: packages/core/src/contracts/session.ts:22
The current session ID.
Returns
string
get()
get(
key):unknown
Defined in: packages/core/src/contracts/session.ts:31
Read the value stored under key, or undefined if absent.
Returns unknown — the caller asserts the stored shape. Higher-level
surfaces (the Session facade, ctx.session helpers) layer a generic
<T> cast on top.
Parameters
key
string
Returns
unknown
pull()
pull(
key):unknown
Defined in: packages/core/src/contracts/session.ts:37
Read the value under key and remove it in one step ("read once").
Returns the stored value, or undefined if absent.
Parameters
key
string
Returns
unknown
set()
set(
key,value):void
Defined in: packages/core/src/contracts/session.ts:42
Store value under key, overwriting any existing entry.
Parameters
key
string
value
unknown
Returns
void
has()
has(
key):boolean
Defined in: packages/core/src/contracts/session.ts:47
Report whether key is present in the session.
Parameters
key
string
Returns
boolean
forget()
forget(
key):void
Defined in: packages/core/src/contracts/session.ts:52
Remove a single value from the session.
Parameters
key
string
Returns
void
flush()
flush():
void
Defined in: packages/core/src/contracts/session.ts:57
Remove every value from the session. The session ID is left unchanged.
Returns
void
flash()
flash(
key,value):void
Defined in: packages/core/src/contracts/session.ts:63
Store a value that survives for exactly one subsequent request.
Backs ctx.flash().
Parameters
key
string
value
unknown
Returns
void
regenerate()
regenerate():
void
Defined in: packages/core/src/contracts/session.ts:69
Issue a fresh session ID while preserving the current session data. Call on any privilege change (login) to defend against session fixation.
Returns
void