Providers
Both functions are exported by ngx-cookie-service and by ngx-cookie-service-ssr. Import them from the package whose service you use.
provideCookieOptions()
Section titled “provideCookieOptions()”provideCookieOptions(options: CookieOptions): EnvironmentProvidersDefault options for every set(), delete() and deleteAll() call. Options passed to a call win, undefined values don’t override a default, and a call’s own expires (or maxAge) replaces the default lifetime. See Default options.
export const appConfig: ApplicationConfig = { providers: [provideCookieOptions({ path: '/', secure: true, sameSite: 'Strict' })],};provideCookieEncoding()
Section titled “provideCookieEncoding()”provideCookieEncoding(encoding: CookieEncoding): EnvironmentProviders
type CookieEncoding = 'uri' | 'minimal' | CookieCodec;
interface CookieCodec { encode(value: string, name: string): string; decode(value: string, name: string): string;}How values are encoded when written and decoded when read. Names always use encodeURIComponent. See Value encoding.
export const appConfig: ApplicationConfig = { providers: [provideCookieEncoding('minimal')],};Injection tokens
Section titled “Injection tokens”The providers set these tokens. You rarely need them directly, but they’re exported for tests and advanced setups.
| Token | Type | Set by |
|---|---|---|
COOKIE_OPTIONS |
CookieOptions |
provideCookieOptions() |
COOKIE_ENCODING |
CookieEncoding |
provideCookieEncoding() |