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.13Code :
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,
RohiteshSounds 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.
精彩评论