stevermeister/ngx-cookie-service

Cookies can't be deleted

Closed this issue · 8 comments

Expected Behavior

When using .delete() or .deleteAll() method, cookies should be deleted.

Actual Behavior

When using .delete() or .deleteAll() method, cookies don't delete.

-Same here, using Angular 7.
-Testing in Localhost

This: cookieService.delete('test');
Doesn't work.

I've tried other approaches hinted:

  1. Deleting it by defining Path and Domain:
    cookieService.delete('test', '/', '/');
    This doesn't work neither.

  2. Deleting using the '../' trick as:
    cookieService.delete('test', '../');
    This doesnt work neither.

  3. Then I tried to set the cookie forcing a Path and Domain as:
    this.cookieService.set( 'Test', 'Hello World', 7, '/', '/' );
    Defining Path and Domain and 7 days.
    However, another bug?, the cookie is not set. Also seems this.cookieService.set( 'Test', 'Hello World', 7) fails.

Any hints?Is this library tested against Angular?

Same here! It's pretty annoying, so if would be good to give us any support, thanks

Hey guys, for me the delete method is working, I only specified a path in a previous 'set' call, then if I call delete with that same path, it seems to be working as intended. NB: my path is set to '/' everywhere (in my 'set' and in my 'delete').
However, setting a custom expiring time doesn't seem to work, but that belong to another issue thread I guess...

Thanks for your reply @guigzz, I'll try to use cookies setting always path then.
About custom expiring time: I'm setting expiring time to my cookies and it's working right (but it was not easy to find the solution). You just need to set the "expire" variable as days (don't use milisecs, don't use Date, don't use UTC Time...).

@jjsosa Thanks but I've found my problem, it was totally unrelated to this lib and it was actually working perfectly since the beginning ^^
I just use Brave browser and it seems you cannot set a cookie expiration time more than 7 days ahead of the current time :)

@guigzz I had the same problem with Firefox Developer Edition because it was only saving cookie as a session cookie because of default browser config. Working well in Chrome! hahah

Can you both delete cookies in Chrome?

Hello everyone.

I tested different set, delete and deleteAll calls with various NG versions (4-8) and everything seems to be working just fine (Mac & Windows with various browsers). Therefore, I assume we are dealing with implementation issues here (or anything else related to your cookie setups). Sadly, I do not have the time to help you guys with that, but you can ask the nice people over at StackOverflow for some advice.

Also, I am sorry for the late answer. I am out of office a lot atm. (vacations, conference talks, workshops...).

Cheers

PS: If you feel this is a bug in our service, try to write a test or supply a repo that reproduces the bug.