Collection Session Storage

    The collection session storage persists sessions to a collection in the database.

    collectionStorage(options): Storage

    Creates a that can be used in the sessions middleware.

    Arguments

    • options: Object

    An object with the following properties:

    • collection: ArangoCollection

    The collection that should be used to persist the sessions.If a string is passed instead of a collection it is assumed to be the fullyqualified name of a collection in the current database.

    • ttl: number (Default: 60 * 60)

    The time in seconds since the last update until a session will beconsidered expired.

    • autoUpdate: boolean (Default: true)

    Whether sessions should be updated in the collection every time theyare accessed to keep them from expiring. Disabling this optionwill improve performance but means you will have to take care ofkeeping your sessions alive yourself.

    If a string or collection is passed instead of an options object, it willbe interpreted as the collection option.

    storage.prune(): Array<string>

    Removes all expired sessions from the collection. This method should be calledeven if the pruneExpired option is enabled to clean up abandoned sessions.

    Returns an array of the keys of all sessions that were removed.

    storage.save(session): Session

    Saves (replaces) the given session object in the collection. This method needsto be invoked explicitly after making changes to the session or the changeswill not be persisted. Assigns a new to the session if it previouslydid not have one.

    • session: Session

    A session object.

    Returns the modified session.

    storage.clear(session): boolean

    Removes the session from the collection. Has no effect if the session wasalready removed or has not yet been saved to the collection (i.e. has no _key).

    Arguments

    • session: Session

    A session object.

    Returns true if the session was removed or if it had no effect.