-
24 Aug 2011 12:51 AM #1
Answered: Clearing cookies not functional?
Answered: Clearing cookies not functional?
I am trying to use the cookie clear method:
where the path = / (so I am not passing it), but the cookie remains active in Safari, Chrome and Firefox.Code:Ext.util.Cookies.clear(<Cookie Name>);
Is this a known issue?
-
Best Answer Posted by skirtle
The dot isn't being added by Ext, that's the browser's doing.
It does seem that the clear() method has some issues with domains though. Appears quite simple to workaround, just call set() with an expires date of new Date(0) and the other parameters set correctly.
-
24 Aug 2011 3:00 AM #2
Could you give a specific example of how the cookie is set and what you're using to clear it? If it's set by a response header could you give an example of that?
-
24 Aug 2011 10:11 AM #3
I am handling setting and clearing of cookies on the client side. So I am setting it as below:
I am trying to clear it as:Code:Ext.util.Cookies.set( name, value, Ext.Date.add(new Date(), Ext.Date.DAY, 1000), '/', 'a.b.com', true );
Any idea?Code:Ext.util.Cookies.clear(name);
-
24 Aug 2011 7:47 PM #4
Works for me, 4.0.2 and 4.0.5. Here's my test code if you want to give it a try yourself.
Code:Ext.onReady(function() { Ext.getBody().update('<div></div>'); var state = Ext.getBody().first(); var clear = false; new Ext.button.Button({ renderTo: Ext.getBody(), text: 'Click', handler: function() { if (clear) { Ext.util.Cookies.clear('name'); } else { Ext.util.Cookies.set('name', 'value', Ext.Date.add(new Date(), Ext.Date.DAY, 1000), '/'); } clear = !clear; } }); setInterval(function() { state.update('Cookie value: ' + Ext.util.Cookies.get('name')); }, 100); });
-
24 Aug 2011 11:26 PM #5
Thank you for your response! So I see that when I explicitly pass the domain name 'a.b.com', it doesn't clear the cookie.
When I pass in 'a.b.com' for the domain parameter, the cookie itself contains the domain parameter as '.a.b.com' (notice the dot before a.b.com) - In this case, the clearing does not work.
But, when I pass in null for the domain parameter, the cookie displays the domain parameter as 'a.b.com' (without the dot) - In this case, the clearing works.
Am I doing something wrong here?
-
25 Aug 2011 12:05 AM #6
The dot isn't being added by Ext, that's the browser's doing.
It does seem that the clear() method has some issues with domains though. Appears quite simple to workaround, just call set() with an expires date of new Date(0) and the other parameters set correctly.
-
25 Aug 2011 9:49 AM #7


Reply With Quote
