salemdar / angular2-cookie

Implementation of Angular 1.x $cookies service to Angular 2
MIT License
109 stars 29 forks source link

Parameters for putting are not working #30

Closed bard10 closed 7 years ago

bard10 commented 7 years ago

When i try to put cookie with CookieOptionArgs like this: ` let token: string = 'blahblahblah';

let cookieConfig: CookieOptionsArgs = { path: null, domain: null, expires: null, secure: true };

cookieService.put('accessToken', token, cookieConfig);; ` the function doesn't work (the cookie is not added) but without providing optional parameters the function works perfectly fine.

alanhe421 commented 7 years ago

I met the same problem

salemdar commented 7 years ago

Actually it is working as expected :). You are just overwriting defaults with invalid values. For example, try with this:

let key = 'testCookieKey';
let value = 'testCookieValue';
let opts: CookieOptionsArgs = {
  expires: new Date('2030-07-19')
};
cookieService.put(key, value, opts);
Spawnrad commented 7 years ago

I have the same issue, without optional its working.