Interface Session<Data, FlashData>

Session persists data across HTTP requests.

interface Session<Data, FlashData> {
    data: Partial<Data & {
        [Key in string | number | symbol as `__flash_${Key & string}__`]: FlashData[Key]
    }>;
    id: string;
    flash<Key>(name: Key, value: FlashData[Key]): void;
    get<Key>(name: Key): undefined | (Key extends keyof Data
        ? Data[Key<Key>]
        : undefined) | (Key extends keyof FlashData
        ? FlashData[Key<Key>]
        : undefined);
    has(name: (keyof FlashData | keyof Data) & string): boolean;
    set<Key>(name: Key, value: Data[Key]): void;
    unset(name: keyof Data & string): void;
}

Type Parameters

Properties

Methods

Properties

data: Partial<Data & {
    [Key in string | number | symbol as `__flash_${Key & string}__`]: FlashData[Key]
}>

The raw data contained in this session.

This is useful mostly for SessionStorage internally to access the raw session data to persist.

id: string

A unique identifier for this session.

Note: This will be the empty string for newly created sessions and sessions that are not backed by a database (i.e. cookie-based sessions).

Methods