Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is wrong with my cookie?

 
Joe Wang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people,
I used following code to test Cookie:
........
public void doGet(... req, ... res)throws ...,..{
HttpCookie cookie = new Cookie("userName","someOne");
res.addCookie(cookie);
res.setContentType("text/html");
//Next, get PrintWriter to send response to client
}
.....
The code was successfully compiled and run without any exception.
But, when I checked the temporary directory of IE, where the cookies should be stored, I could not find any cookie file.Why?
Does anybody can tell the reason?
I run it at TomCat on my PC. URL is http://localhost:8080/test/Coo
???
[ October 11, 2003: Message edited by: Joe Wang ]
 
Sathya Sankar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,
Cookies will be stored on a per session basis if their expirati0on time is not set. This means that the cookie will be stored only in the RAM and not onto the hardisk. Hence when the last browser window of that session closes, the cookie will be lost forever.
You can set the cookie age using the setMaxAge method of the Cookie class. Exammple code,
Ciao,
GSS
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic