diff --git a/projects/ngx-cookie-service/src/lib/cookie.service.ts b/projects/ngx-cookie-service/src/lib/cookie.service.ts index 7cd5157..3e918f1 100644 --- a/projects/ngx-cookie-service/src/lib/cookie.service.ts +++ b/projects/ngx-cookie-service/src/lib/cookie.service.ts @@ -176,7 +176,7 @@ export class CookieService { set( name: string, - value: string, + value: string | number, expiresOrOptions?: CookieOptions['expires'] | CookieOptions, path?: CookieOptions['path'], domain?: CookieOptions['domain'], @@ -186,7 +186,9 @@ export class CookieService { if (!this.documentIsAccessible) { return; } - + if (typeof value === 'number') { + value = value.toString(); + } if (typeof expiresOrOptions === 'number' || expiresOrOptions instanceof Date || path || domain || secure || sameSite) { const optionsBody = { expires: expiresOrOptions as CookieOptions['expires'],