ngx-cookie-service

  • Version 12.0.3
  • Published
  • 121 kB
  • 1 dependency
  • MIT license

Install

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

Overview

An (aot ready) angular (4.2+) cookie service

Index

Classes

class CookieService

class CookieService {}

    constructor

    constructor(document: any, platformId: any);

      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

      method delete

      delete: (
      name: string,
      path?: string,
      domain?: string,
      secure?: boolean,
      sameSite?: 'Lax' | 'None' | 'Strict'
      ) => 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

      method deleteAll

      deleteAll: (
      path?: string,
      domain?: string,
      secure?: boolean,
      sameSite?: 'Lax' | 'None' | 'Strict'
      ) => 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

      method get

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

        Parameter name

        Cookie name

        Returns

        property value

      method getAll

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

        Returns

        all the cookies in json

      method set

      set: {
      (
      name: string,
      value: string,
      expires?: number | Date,
      path?: string,
      domain?: string,
      secure?: boolean,
      sameSite?: 'Lax' | 'None' | 'Strict'
      ): void;
      (
      name: string,
      value: string,
      options?: {
      expires?: number | Date;
      path?: string;
      domain?: string;
      secure?: boolean;
      sameSite?: 'Lax' | 'None' | 'Strict';
      }
      ): 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 sameSite

        OWASP samesite token Lax, None, or Strict. Defaults to Lax

      • 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 Secure flag sameSite OWASP samesite token Lax, None, or Strict. Defaults to Lax

        Parameter name

        Cookie name

        Parameter value

        Cookie value

        Parameter options

        Body with cookie's params

      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>