Session Storages

    The built-in session storages generally provide the following attributes:

    • uid: string (Default: null)

      A unique identifier indicating the active user.

    • created: number (Default: )

      The numeric timestamp of when the session was created.

    Generates a new session object representing an empty session. The empty session object should not be persisted unless necessary. The return value will be exposed by the middleware as the session property of the request object if no session identifier was returned by the session transports and auto-creation is not explicitly disabled in the session middleware.

    Examples

    storage.fromClient(sid): Session | null

    Resolves or deserializes a session identifier to a session object.

    Arguments

    • sid:

      Session identifier to resolve or deserialize.

    Examples

    storage.forClient(session): string | null

    Derives a session identifier from the given session object.

    Arguments

    • session: Session

      Session to derive a session identifier from.

    Returns a session identifier for the session represented by the given session object. This method will be called with the session property of the request object unless that property is empty (e.g. ).