ngx-cookie-service

  • Version 18.0.0
  • Published
  • 69.8 kB
  • 1 dependency
  • MIT license

Install

npm i ngx-cookie-service
yarn add ngx-cookie-service
pnpm add ngx-cookie-service

Overview

Angular cookie service

Index

Classes

class CookieService

class CookieService {}

    constructor

    constructor(document: Document, platformId: any);

      property ɵfac

      static ɵfac: i0.ɵɵFactoryDeclaration<CookieService, never>;

        property ɵprov

        static ɵprov: i0.ɵɵInjectableDeclaration<CookieService>;

          method check

          check: (name: string) => boolean;
          • Return true if Document is accessible, otherwise return false

            Parameter name

            Cookie name

            Returns

            boolean - whether cookie with specified name exists

            @author: Stepan Suvorov @since: 1.0.0

          method delete

          delete: (
          name: string,
          path?: CookieOptions['path'],
          domain?: CookieOptions['domain'],
          secure?: CookieOptions['secure'],
          sameSite?: SameSite
          ) => void;
          • Delete cookie by name

            Parameter name

            Cookie name

            Parameter path

            Cookie path

            Parameter domain

            Cookie domain

            Parameter secure

            Cookie secure flag

            Parameter sameSite

            Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite

            @author: Stepan Suvorov @since: 1.0.0

          method deleteAll

          deleteAll: (
          path?: CookieOptions['path'],
          domain?: CookieOptions['domain'],
          secure?: CookieOptions['secure'],
          sameSite?: SameSite
          ) => void;
          • Delete all cookies

            Parameter path

            Cookie path

            Parameter domain

            Cookie domain

            Parameter secure

            Is the Cookie secure

            Parameter sameSite

            Is the cookie same site

            @author: Stepan Suvorov @since: 1.0.0

          method get

          get: (name: string) => string;
          • Get cookies by name

            Parameter name

            Cookie name

            Returns

            property value

            @author: Stepan Suvorov @since: 1.0.0

          method getAll

          getAll: () => { [key: string]: string };
          • Get all cookies in JSON format

            Returns

            all the cookies in json

            @author: Stepan Suvorov @since: 1.0.0

          method set

          set: {
          (
          name: string,
          value: string,
          expires?: CookieOptions['expires'],
          path?: CookieOptions['path'],
          domain?: CookieOptions['domain'],
          secure?: CookieOptions['secure'],
          sameSite?: SameSite,
          partitioned?: CookieOptions['partitioned']
          ): void;
          (name: string, value: string, options?: CookieOptions): void;
          };
          • Set cookie based on provided information

            Parameter name

            Cookie name

            Parameter value

            Cookie value

            Parameter expires

            Number of days until the cookies expires or an actual Date

            Parameter path

            Cookie path

            Parameter domain

            Cookie domain

            Parameter secure

            Secure flag

            Parameter partitioned

            Partitioned flag

            Parameter sameSite

            OWASP same site token Lax, None, or Strict. Defaults to Lax

            @author: Stepan Suvorov @since: 1.0.0

          • Set cookie based on provided information

            Cookie's parameters: expires Number of days until the cookies expires or an actual Date path Cookie path domain Cookie domain secure flag sameSite OWASP same site token Lax, None, or Strict. Defaults to Lax

            Parameter name

            Cookie name

            Parameter value

            Cookie value

            Parameter options

            Body with cookie's params

            @author: Stepan Suvorov @since: 1.0.0

          Interfaces

          interface CookieOptions

          interface CookieOptions {}

            property domain

            domain?: string;

              property expires

              expires?: number | Date;

                property partitioned

                partitioned?: boolean;

                  property path

                  path?: string;

                    property sameSite

                    sameSite?: SameSite;

                      property secure

                      secure?: boolean;

                        Type Aliases

                        type SameSite

                        type SameSite = 'Lax' | 'None' | 'Strict';

                          Package Files (2)

                          Dependencies (1)

                          Dev Dependencies (0)

                          No dev dependencies.

                          Peer Dependencies (2)

                          Badge

                          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/ngx-cookie-service.

                          • Markdown
                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ngx-cookie-service)
                          • HTML
                            <a href="https://www.jsdocs.io/package/ngx-cookie-service"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>