method SessionService.prototype.commit
Since 0.2.0
SessionService.prototype.commit(
ctx: IRequestContext,
session: Session
): Promise<void>

Writes the session back, when it needs writing.

A clean session emits no header at all: committing on every request would rewrite the cookie on pure reads and defeat downstream caching.

Parameters

ctx: IRequestContext

The request context

session: Session

The session returned by SessionService.load

Return Type

Promise<void>

Throws

SessionTooLargeError

If the serialized cookie exceeds the budget

Usage

import { SessionService } from "session-plugin/src/index.ts";