Stone.js API
    Preparing search index...

    Class representing a collection of Cookies.

    Index
    • Create a CookieCollection.

      Parameters

      • Optionalcookie: string

        String cookie from header.

      • options: CookieOptions = {}

        Cookies options.

      • Optionalsecret: string

        Secret value to sign and unsign cookies.

      Returns CookieCollection

    • Add a cookie to the collection.

      Parameters

      • name: string

        Cookie name.

      • value: unknown

        Cookie value.

      • options: CookieOptions = {}

        Cookie options.

      Returns this

    • Get all cookies in the collection.

      Type Parameters

      • S extends boolean

      Parameters

      • serialize: S = ...

        If true, serialize the cookies.

      Returns S extends true ? string[] : Record<string, unknown>

    • Clear all cookies from the collection.

      Parameters

      • force: boolean = false

        If true, remove only from collection without setting expiry.

      Returns this

    • Get a cookie from the collection.

      Parameters

      • name: string

        Cookie name.

      Returns Cookie

      Cookie value.

    • Get a cookie from the collection.

      Parameters

      • name: string

        Cookie name.

      • fallback: Cookie

        Fallback value if the cookie does not exist.

      Returns Cookie

      Cookie value.

    • Get a cookie value from the collection.

      Type Parameters

      • ValueType = unknown

      Parameters

      • name: string

        Cookie name.

      Returns ValueType

      Cookie value.

    • Get a cookie value from the collection.

      Type Parameters

      • ValueType = unknown

      Parameters

      • name: string

        Cookie name.

      • fallback: ValueType

        Fallback value if the cookie does not exist.

      Returns ValueType

      Cookie value.

    • Check if the collection has a cookie.

      Parameters

      • name: string

        Cookie name.

      Returns boolean

    • Check if the collection is empty.

      Returns boolean

    • Remove a cookie from the collection.

      Parameters

      • name: string

        Cookie name to remove.

      • options: CookieOptions = {}

        Cookie options.

      • force: boolean = false

        If true, remove only from collection without setting expiry.

      Returns this

    • Set secure flag for all cookies in the collection.

      Parameters

      • value: boolean = false

        Whether the cookies are secure.

      Returns this

    • Set options for all cookies in the collection.

      Parameters

      Returns this

    • Set secret for signing and unsigning cookies.

      Parameters

      • value: string

        Secret value.

      Returns this

    • Update a cookie in the collection.

      Parameters

      • name: string

        Cookie name.

      • value: unknown

        New cookie value.

      • options: CookieOptions = {}

        Cookie options.

      Returns this

    • Create a CookieCollection.

      Parameters

      • Optionalcookie: string

        String cookie from header.

      • options: CookieOptions = {}

        Cookies options.

      • Optionalsecret: string

        Secret value to sign and unsign cookies.

      Returns CookieCollection