开发者

Cookies are not setting in some clients

开发者 https://www.devze.com 2023-02-03 10:18 出处:网络
I am facing a slightly weird problem. I am setting a cookie in my Jav开发者_JAVA技巧a Servlet, and accessing it later. This works when I am accessing my webapp from certain machines. However, from oth

I am facing a slightly weird problem. I am setting a cookie in my Jav开发者_JAVA技巧a Servlet, and accessing it later. This works when I am accessing my webapp from certain machines. However, from others, it is not working.

On further analysis, I found that the cookie is not setting in some browsers. However, in the same browser, another cookie I am setting in another part of my webapp, is successfully stored. Anyone else has faced similar issues before?

Details : OS : Windows XP

Browser : Mozilla Firefox 3.6.13

Code :

tempCookie = new Cookie("CN.checkCookie", "try this!!!");
tempCookie.setMaxAge(60 * 60 * 24 * 365);
response.addCookie(tempCookie);

Another observation :

When the cookie setting fails, I have also seen that variables stored previously in the session variable, are also lost.

Cheers,

Rohitesh


Sounds like privacy configuration in your browser. Check it. As far as I remember your can configure privacy in browsers per URL. This may explain this strange behavior.

Additionally I'd recommend you to call setDomain() and setPath() explicitly.

0

精彩评论

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

关注公众号