AdonisJS API
    Preparing search index...

    Interface SessionConfig

    Base configuration interface for session management. Used by the session manager and middleware to control session behavior.

    const config: SessionConfig = {
    enabled: true,
    cookieName: 'my_app_session',
    age: '2 hours',
    cookie: {
    httpOnly: true,
    secure: true,
    sameSite: 'strict'
    }
    }
    interface SessionConfig {
        enabled: boolean;
        cookieName: string;
        age: string | number;
        cookie: Partial<CookieOptions>;
        renewMissingSessionId?: boolean;
        refreshCookie?: boolean;
    }

    Hierarchy (View Summary)

    Index
    enabled: boolean

    Whether session management is enabled for the application

    cookieName: string

    Name of the cookie used to store the session ID

    age: string | number

    Maximum age of the session data and session ID cookie. Session data is automatically cleaned up after this duration of inactivity. Value can be a time expression (e.g. '2 hours') or number of seconds. Cookie duration is also set to this value unless clearWithBrowser is enabled.

    cookie: Partial<CookieOptions>

    Additional cookie options for the session ID cookie. Excludes maxAge and expires as they're controlled by age and clearWithBrowser.

    renewMissingSessionId?: boolean

    Whether to give a new session ID when the cookie names a session the store does not have (expired or destroyed). Defaults to false.

    When true, the ID of an ended session is never used again, so a late request that read the old session cannot write it back. The session is "fresh". A session without data then gets a new ID on each request, so do not use session.sessionId as a stable key for a session without data.

    refreshCookie?: boolean

    Whether to send the session ID cookie on every response, which refreshes its Max-Age. Defaults to true.

    When false, the cookie is only sent when the session ID changes (new session, regenerate) or the browser did not send one. A late response then cannot put back in the browser a session ID it has left, e.g. the guest ID after a login that regenerated the session.

    The cookie Max-Age is no longer refreshed, so the browser drops the cookie age after the session started. Pair it with clearWithBrowser and let the store expire inactive sessions.