Fail to remove cookie in Firefox with Java; Firefox creates a new cookie with dot at the head
I have this cookie in Firefox:
name:Vanilla-Volatile
value:1-1313808454|54614728ee113ab09e4db5c863cd5cfa|1313635654|1|1开发者_如何学Go313808454
domain:zhu13890.prod.xxxx.corp
path:/
Then, I try to reset the cookie in Java with this code:
def c = new Cookie("Vanilla-Volatile", null);
c.setDomain("zhu13890.prod.xxxx.corp");
c.setPath('/');
response.addCookie(c);
Instead of resetting the cookie, Firefox creates a new cookie with domain=.zhu13890.prod.xxxx.corp
(notice the '.' at the head.)
Is there a workaround for this issue?
I'm using Firefox version 3.6.
Remove this line:
c.setDomain("zhu13890.prod.xxxx.corp");
A cookie can either be set for a single host (the default) or for a whole domain. Apparently, you want to set it for a single host ("zhu13890.prod.xxxx.corp", the host where this script runs). So you should not specify a domain.
精彩评论