• Version 0.9.0
  • Published
  • 9.24 kB
  • 4 dependencies
  • MIT license


npm i @types/cookies
yarn add @types/cookies
pnpm add @types/cookies


TypeScript definitions for cookies



variable Cookies

const Cookies: CookiesFunction;


    interface Cookie {}

      property domain

      domain: string;

        property expires

        expires: Date;

          property httpOnly

          httpOnly: boolean;

            property maxage

            maxage: number;
            • "maxage" is deprecated, use "maxAge" instead

            property maxAge

            maxAge: number;

              property name

              name: string;

                property overwrite

                overwrite: boolean;

                  property partitioned

                  partitioned: boolean;

                    property path

                    path: string;

                      property priority

                      priority: boolean;

                        property sameSite

                        sameSite: boolean;

                          property secure

                          secure: boolean;

                            property value

                            value: string;

                              method toHeader

                              toHeader: () => string;

                                method toString

                                toString: () => string;

                                  interface Cookies

                                  interface Cookies {}

                                    property request

                                    request: IncomingMessage;

                                      property response

                                      response: ServerResponse;

                                        property secure

                                        secure: boolean;

                                          method get

                                          get: (name: string, opts?: Cookies.GetOption) => string | undefined;
                                          • This extracts the cookie with the given name from the Cookie header in the request. If such a cookie exists, its value is returned. Otherwise, nothing is returned.

                                          method set

                                          set: (name: string, value?: string | null, opts?: Cookies.SetOption) => this;
                                          • This sets the given cookie in the response and returns the current context to allow chaining.If the value is omitted, an outbound header with an expired date is used to delete the cookie.

                                          interface GetOption

                                          interface GetOption {}

                                            property signed

                                            signed: boolean;

                                              interface Option

                                              interface Option {}

                                                property keys

                                                keys?: string[] | Keygrip | undefined;

                                                  property secure

                                                  secure?: boolean | undefined;

                                                    interface SetOption

                                                    interface SetOption {}

                                                      property domain

                                                      domain?: string | undefined;
                                                      • a string indicating the domain of the cookie (no default).

                                                      property expires

                                                      expires?: Date | undefined;
                                                      • a Date object indicating the cookie's expiration date (expires at the end of session by default).

                                                      property httpOnly

                                                      httpOnly?: boolean | undefined;
                                                      • a boolean indicating whether the cookie is only to be sent over HTTP(S), and not made available to client JavaScript (true by default).

                                                      property maxAge

                                                      maxAge?: number | undefined;
                                                      • a number representing the milliseconds from Date.now() for expiry

                                                      property overwrite

                                                      overwrite?: boolean | undefined;
                                                      • a boolean indicating whether to overwrite previously set cookies of the same name (false by default). If this is true, all cookies set during the same request with the same name (regardless of path or domain) are filtered out of the Set-Cookie header when setting this cookie.

                                                      property partitioned

                                                      partitioned?: boolean | undefined;
                                                      • a boolean indicating whether to partition the cookie in Chrome for the CHIPS Update (false by default). If this is true, Cookies from embedded sites will be partitioned and only readable from the same top level site from which it was created.

                                                      property path

                                                      path?: string | undefined;
                                                      • a string indicating the path of the cookie (/ by default).

                                                      property priority

                                                      priority?: 'low' | 'medium' | 'high' | undefined;
                                                      • a string indicating the cookie priority. This can be set to 'low', 'medium', or 'high'.

                                                      property sameSite

                                                      sameSite?: 'strict' | 'lax' | 'none' | boolean | undefined;
                                                      • a boolean or string indicating whether the cookie is a "same site" cookie (false by default). This can be set to 'strict', 'lax', or true (which maps to 'strict').

                                                      property secure

                                                      secure?: boolean | undefined;
                                                      • a boolean indicating whether the cookie is only to be sent over HTTPS (false by default for HTTP, true by default for HTTPS).

                                                      property secureProxy

                                                      secureProxy?: boolean | undefined;
                                                      • "secureProxy" option is deprecated; use "secure" option, provide "secure" to constructor if needed

                                                      property signed

                                                      signed?: boolean | undefined;
                                                      • a boolean indicating whether the cookie is to be signed (false by default). If this is true, another cookie of the same name with the .sig suffix appended will also be sent, with a 27-byte url-safe base64 SHA1 value representing the hash of cookie-name=cookie-value against the first Keygrip key. This signature key is used to detect tampering the next time a cookie is received.

                                                      Type Aliases

                                                      type CookieAttr

                                                      type CookieAttr = SetOption;

                                                        type ICookies

                                                        type ICookies = Cookies;
                                                        • for backward-compatibility

                                                        type IOptions

                                                        type IOptions = SetOption;
                                                        • for backward-compatibility

                                                        Package Files (1)

                                                        Dependencies (4)

                                                        Dev Dependencies (0)

                                                        No dev dependencies.

                                                        Peer Dependencies (0)

                                                        No peer dependencies.


                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/cookies.

                                                        • Markdown
                                                        • HTML
                                                          <a href="https://www.jsdocs.io/package/@types/cookies"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>