ngx-cookie-service: Cookie not being set in Chrome versions > 80 with ngx-cookie-service 2.4.0
Expected Behavior
Using ngx-cookie-service 2.4.0, when a cookie is being set with key, value, Chrome browser should set the cookies in all browsers. this.cookieService.set(‘runOffline’, ‘true’);
Actual Behavior
No cookie is being set in the chrome browsers with version > 80(the latest version).
Reason
For some reason there are other libraries that are creating cookies and the cookies found in document.cookie does not start with a space. So setting a cookie in this condition does not actually set the cookie.
Steps to Reproduce the Problem
Just download the latest version of chrome and set the cookie
Specifications
- Version: 2.4.0
- Browser: Chrome Version 80.0.3987.132
- OS: Ubuntu 18.04
Steps to Reproduce the Problem
Set the cookie the traditional way by leaving a space initially eg.
document.cookie = " runOffline=true; " + document.cookie
Notice the space in the beginning for some reason works well.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 35 (12 by maintainers)
Version 3.0 still doesn’t work
macOS, Chrome Version 80.0.3987.132 (Official Build) (64-bit)
temporary fix: pass all arguments when setting a new cookie. this.cookieService.set(‘name’, ‘John’, null, null, null, null, null);
@stevermeister yes it should fix it.
But in the case where a cookie is set with the samesite = none (via the cookieService.set method) the secure flag always has to be set. So I don’t know if ngx-cookie-service should override the secure flag if mode is
noneDoing this will result with a reject from the browser :
Doing this will work
Doing this will work
worked for me after upgrading version to 3.0.1, Thanks 😃
None of those actually works. Chrome 80 unable to set cookie.
@stevermeister I made a repo where you can see the warning : https://github.com/Yohandah/ngx-cookie-bug-secure
@Yohandah could you please check version 3.0.0?