sveltekit-service-manager - v1.1.0
    Preparing search index...

    Class Cookies

    Minimal SvelteKit-compatible cookie implementation for non-SvelteKit servers. Reads cookies from the incoming Request and collects Set-Cookie values for the outgoing response.

    Implements

    • Cookies
    Index

    Constructors

    • Parameters

      • request: Request
      • setCookieHeader: (name: string, value: string, opts: CookieSerializeOptions) => void
      • Optionaloptions: CookieParseOptions

      Returns Cookies

    Methods

    • Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.

      You must specify a path for the cookie. In most cases you should explicitly set path: '/' to make the cookie available throughout your app. You can use relative paths, or set path: '' to make the cookie only available on the current path and its children

      Parameters

      • name: string

        the name of the cookie

      • opts: CookieSerializeOptions & { path: string }

        the options, passed directly to cookie.serialize. The path must match the path of the cookie you want to delete. See documentation here

      Returns void

    • Gets a cookie that was previously set with cookies.set, or from the request headers.

      Parameters

      • name: string

        the name of the cookie

      Returns string | undefined

    • Gets all cookies that were previously set with cookies.set, or from the request headers.

      Returns { name: string; value: string }[]

    • Serialize a cookie name-value pair into a Set-Cookie header string, but don't apply it to the response.

      The httpOnly and secure options are true by default (except on http://localhost, where secure is false), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The sameSite option defaults to lax.

      You must specify a path for the cookie. In most cases you should explicitly set path: '/' to make the cookie available throughout your app. You can use relative paths, or set path: '' to make the cookie only available on the current path and its children

      Parameters

      • name: string

        the name of the cookie

      • value: string

        the cookie value

      • opts: CookieSerializeOptions & { path: string }

        the options, passed directly to cookie.serialize. See documentation here

      Returns string

    • Sets a cookie. This will add a set-cookie header to the response, but also make the cookie available via cookies.get or cookies.getAll during the current request.

      The httpOnly and secure options are true by default (except on http://localhost, where secure is false), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The sameSite option defaults to lax.

      You must specify a path for the cookie. In most cases you should explicitly set path: '/' to make the cookie available throughout your app. You can use relative paths, or set path: '' to make the cookie only available on the current path and its children

      Parameters

      • name: string

        the name of the cookie

      • value: string

        the cookie value

      • opts: CookieSerializeOptions & { path: string }

        the options, passed directly to cookie.serialize. See documentation here

      Returns void