stevermeister / ngx-cookie-service

Angular (4.2+ ...12) service for cookies. Originally based on the `ng2-cookies` library.

Home Page:https://www.npmjs.com/package/ngx-cookie-service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting a cookie value is expecting browser reload in v15.0.0

SAkhil95 opened this issue · comments

Describe the bug

We were using ngx-cookie-service v14 with Angular 14 for sometime now.
Recently, we upgraded Angular to v15 and ngx-cookie-service to 15.0.0 as well.

In ngx-cookie-service v14, when we used to set a cookie, we observed the cookie getting added on the fly in the dev tools "Application" tab
but with v15, we noticed the cookie is getting set/added only after I refresh/reload my browser.

Steps to Reproduce

Use Angular v15 with ngx-cookie-service 15.0.0

Inspect application tab in developer tools and set a cookie from Angular app.
You will notice the cookie didn't get added.

Refresh/reload the browser and you will now see the cookie is appearing in the cookies list under Applications tab

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

https://stackblitz.com/edit/ngx-cookie-service-v15-issue (click open in new tab)

Expected behaviour

The cookie gets updated in cookie section under "Applcations tab" as soon as I set the cookie without need of reloading.

What version of the library you see this issue?

15.0.0

What version of Angular are you using?

Angular 13

Screenshots

No response

Desktop? Please complete the following information

No response

Mobile? Please complete the following information

No response

Anything else?

Example is from 16.0.0 but it's still the same for 15.0.0 as well.

Selected Angular version as 13 as they are no further options.

If this is identified as bug, please fix in v15 as well

Hello 👋 @SAkhil95
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

I was able to fix it using..
this.cookie.set('something', 'someValue', { path: '/' });

this looked like a workaround to me, pls suggest

You don't need to reload browser. Just refresh in cookies tab. It will show the cookie

Screenshot 2023-06-21 at 9 50 14 AM