ReadonlyidThe session identifier. Stable for the session's lifetime until
ISession.regenerate is called.
ReadonlyisWhether this session was created for this request rather than restored
from a cookie. true for a first visit, and for a request whose cookie was
missing, expired, or failed authentication.
Removes every key, keeping the session and its id.
Use ISession.destroy to end the session instead.
Removes a key and marks the session for commit.
Session key
true when a value was removed
Ends the session: clears the data, deletes any stored entry, and instructs the client to drop the cookie.
Reads a value.
The expected value type; validate before trusting it, since the payload survived a JSON round-trip
Session key
The value, or undefined when absent
Reports whether a key is present.
Session key
true when the key exists
Issues a new session id while keeping the current data.
Call this on privilege change (most importantly immediately after login) so that a session id an attacker planted before authentication does not carry into the authenticated session — session fixation. On the store strategy the previous entry is deleted, making this a real revocation.
Writes a value and marks the session for commit.
Passing undefined removes the key instead of storing it. undefined is not
JSON-serializable, so storing it would make ISession.has report a
key that serialization then drops — presence would be true before a commit
and false after the next load.
The value type
Session key
Value to store; must be JSON-serializable. undefined removes the key
Returns a plain snapshot of the current data.
A detached copy; mutating it does not affect the session
Per-request session handle.
Obtained from
ISessionService.from(or the plugin'sgetSessionhelper). Mutations are buffered and written back by the session middleware after the handler returns, so a handler never issues aSet-Cookieitself.Example
Since
0.2.0