Comments (7)
There is an easy workaround: Just before deleting the cookie, set it again to any value (an empty string should be fine). Firefox will of course "revive" the cookie, and clearing it will work at that point. For example:
// Let's delete the 'arepa' cookie:
cookieService.write('arepa', '');
cookieService.clear('arepa');
// The 'arepa' cookie is now gone.
from ember-cookies.
Thanks for the details @eighthjouster! I just confirmed the respective test breaks in Firefox.
from ember-cookies.
Any Error? Is the cookie just not cleared? Does it have a path, domain, expiration etc.?
from ember-cookies.
I can confirm that this is a bug, although it's not an ember-cookie bug. It's a Firefox bug (see: https://bugzilla.mozilla.org/show_bug.cgi?id=691973 ), and it's only related to cookies that are already expired.
Chrome isn't affected, so ember-cookies works flawlessly there.
Steps to reproduce:
- Create a cookie with an expiration timestamp 10 seconds from now.
- Wait until it expires.
- Check Firefox's cookies. The cookie will still be there.
- Attempt to delete cookie via Javascript. Nope. Not happening.
Here's a simple HTML (must be accessed through a local web server, or enable cookies with local files) that can help reproduce the problem (keep the dev console open in the Local Storage/Cookies section):
<html>
<body>
<input type="button" id="cookiebutton" onclick="cookieButton()" value="Create cookie"></button>
<input type="button" id="cookiedeletebutton" onclick="hardDeleteCookie()" value="HARD delete cookie"></button>
<div id="cookiemessage">No cookie (supposedly)</div>
<script>
function cookieButton() {
if (cookiebutton.value === 'Create cookie') {
cookiebutton.value = 'Delete cookie';
createCookie();
setTimeout(announceExpiredCookie, 5000);
}
else if (cookiebutton.value === 'Delete cookie') {
deleteCookie();
}
}
function createCookie() {
document.cookie = 'oneCookie=1;max-age=5;';
cookiemessage.innerHTML = 'Cookie created.';
}
function deleteCookie() {
document.cookie = 'oneCookie=1;expires=Thu, 01 Jan 1970 00:00:01 GMT';
cookiemessage.innerHTML = 'Cookie deleted (supposedly)';
}
function hardDeleteCookie() {
document.cookie = 'oneCookie=1;max-age=5;';
document.cookie = 'oneCookie=1;expires=Thu, 01 Jan 1970 00:00:01 GMT';
cookiemessage.innerHTML = 'Cookie hard deleted!';
}
function announceExpiredCookie() {
cookiemessage.innerHTML = 'Cookie deleted (supposedly) or expired.';
}
</script>
</body>
</html>
from ember-cookies.
This issue is happening for expiry time, which is not getting set properly. Facing this issue in chrome also.
I'm doing this for clearing, which cleared on expired.
if(cookies.read([key])) {
cookies.write([key], '', { path: '/', expires: moment().toDate()});
}
from ember-cookies.
@trdp30 how is that cookie written in the first place?
from ember-cookies.
I'm seeing issue with this in Chrome now.
from ember-cookies.
Related Issues (20)
- New release be made to utilize exists method HOT 1
- clearAllCookies doesn't seem to work in headless Chrome 68 HOT 5
- DEPRECATION: Use of `merge` has been deprecated.
- Expire On Cookie HOT 1
- DEPRECATION: Use of `merge` has been deprecated HOT 2
- An in-range update of ember-cli-babel is breaking the build 🚨 HOT 3
- Fastboot causes double decoding HOT 2
- Addon causes linked apps to error during build. "Babel loaded v6.x.x" HOT 1
- npm deploy build step failed HOT 2
- `Cannot read property 'split' of undefined` error in tests when upgrading to ember 3.13.0 HOT 1
- [0.5.1 Regression] TypeError: Cannot read property 'isFastBoot' of undefined HOT 1
- Add SameSite=None support (and UA check?) HOT 3
- nodetest task HOT 1
- Setting max age in FastBoot
- Add a timeout to CI GitHub workflow for test step
- cookies not working
- Dependency Dashboard
- Cut new release HOT 3
- Convert addon to V2 HOT 2
- TypeError: can't access dead object HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-cookies.