Cookies for JS
    Preparing search index...

    Class CookieStore

    Provides access to the HTTP Cookies.

    Hierarchy

    • EventTarget
      • CookieStore

    Implements

    • AsyncIterable<[string, any], void, void>
    Index

    Constructors

    Properties

    defaults: CookieOptions

    The default cookie options.

    changeEvent: "cookies:change"

    The change event type.

    Accessors

    • get keys(): Promise<Set<string>>

      The keys of this cookie store.

      Returns Promise<Set<string>>

    • get length(): Promise<number>

      The number of entries in this cookie store.

      Returns Promise<number>

    Methods

    • Returns a new iterator that allows iterating the entries of this cookie store.

      Returns AsyncIterator<[string, any], void, void>

      An iterator for the entries of this cookie store.

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: null | EventListenerOrEventListenerObject
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Removes the value associated with the specified key.

      Type Parameters

      • T

      Parameters

      • key: string

        The cookie name.

      • options: CookieOptions = {}

        The cookie options.

      Returns Promise<null | T>

      The value associated with the key before it was removed.

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Gets the deserialized value associated with the specified key.

      Type Parameters

      • T

      Parameters

      • key: string

        The cookie name.

      Returns Promise<null | T>

      The cookie value, or null if the key does not exist or the value cannot be deserialized.

    • Gets a value indicating whether this cookie store contains the specified key.

      Parameters

      • key: string

        The cookie name.

      Returns Promise<boolean>

      true if this cookie store contains the specified key, otherwise false.

    • Registers a function that will be invoked whenever the change event is triggered.

      Parameters

      • listener: (event: CookieEvent) => void

        The event handler to register.

      Returns this

      This instance.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • callback: null | EventListenerOrEventListenerObject
      • Optionaloptions: boolean | EventListenerOptions

      Returns void