开发者

Fail to remove cookie in Firefox with Java; Firefox creates a new cookie with dot at the head

开发者 https://www.devze.com 2023-03-31 01:57 出处:网络
I have this cookie in Firefox: name:Vanilla-Volatile value:1-1313808454|54614728ee113ab09e4db5c863cd5cfa|1313635654|1|1开发者_如何学Go313808454

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消