stevermeister/ngx-cookie-service

Able to access cookie even after deletion

ranoy opened this issue · 4 comments

ranoy commented

Describe the bug

I am able to retrieve cookie even after it has been deleted.
I checked the code and while deleting we set the expiry to an old date. But there is no such check while retrieving

Steps to Reproduce

Please check in the console, we have cookie value logged even after deletion.

Please provide a link to a minimal reproduction of the bug. StackBlitz, CodePen or CodeSanBox

https://stackblitz.com/edit/angular-ivy-txzeto?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html

Expected behaviour

I should not be able to retrieve cookie after deletion

What version of the library you see this issue?

12.x.x

What version of Angular are you using?

Angular 12

Screenshots

No response

Desktop? Please complete the following information

No response

Mobile? Please complete the following information

No response

Anything else?

No response

Hello 👋 @ranoy
Thank you for raising an issue. We will investigate into the issue and get back to you as soon as possible. Please make sure you have given us as much context as possible.
Feel free to raise a PR if you can fix the issue

@ranoy The cookie is being deleted as expected. Your code has a bug, see this https://stackblitz.com/edit/angular-ivy-ma8kdt?file=src%2Fapp%2Fapp.component.ts for updated version

ranoy commented

indeed my bad, there was a bug in the example. But in my case I reload after deleting and then sometimes application still reads the deleted cookie. I will try to update the stackblitz and check. For now instead of delete I am overriding the value with null