Session Middleware

    The session middleware adds the session and sessionStorage properties to the request object and deals with serializing and deserializing the session as well as extracting session identifiers from incoming requests and injecting them into outgoing responses.

    Examples

    sessionMiddleware(options): Middleware

    Creates a session middleware.

    An object with the following properties:

    • storage:

    Storage that will be used to persist the sessions.

    The storage is also exposed as the sessionStorage on all request objects and as the storage property of the middleware.

    If a string or collection is passed instead of a Storage, it will be used to create a .

    The transports are also exposed as the transport property of the middleware.

    If the string is passed instead of a Transport, the Cookie Transport will be used with the default settings instead.

    If the string "header" is passed instead of a Transport, the will be used with the default settings instead.

    • autoCreate: boolean (Default: true)

    If enabled the session storage’s new method will be invoked to create an empty session whenever the transport failed to return a session for the incoming request. Otherwise the session will be initialized as .