AdonisJS API
    Preparing search index...

    Interface SessionStoreContract

    Contract interface that every session store implementation must follow. Defines the basic CRUD operations for session data persistence.

    class CustomStore implements SessionStoreContract {
    async read(sessionId: string) {
    // Read session data from your storage
    return await this.storage.get(sessionId)
    }

    async write(sessionId: string, data: SessionData) {
    // Write session data to your storage
    await this.storage.set(sessionId, data)
    }

    async destroy(sessionId: string) {
    // Remove session data from storage
    await this.storage.delete(sessionId)
    }

    async touch(sessionId: string) {
    // Update expiry/last accessed time
    await this.storage.touch(sessionId)
    }
    }
    interface SessionStoreContract {
        read(
            sessionId: string,
        ): SessionData | Promise<SessionData | null> | null;
        write(sessionId: string, data: SessionData): void | Promise<void>;
        destroy(sessionId: string): void | Promise<void>;
        touch(sessionId: string): void | Promise<void>;
    }

    Hierarchy (View Summary)

    Index
    • Writes session data for a given session ID to the persistence store

      Parameters

      • sessionId: string

        Unique identifier for the session

      • data: SessionData

        Session data to store

      Returns void | Promise<void>

    • Removes session data for a given session ID from the persistence store

      Parameters

      • sessionId: string

        Unique identifier for the session to remove

      Returns void | Promise<void>

    • Updates the lifetime/expiry of a session without modifying the session data

      Parameters

      • sessionId: string

        Unique identifier for the session to touch

      Returns void | Promise<void>