my dog learned polymorphism
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What is wrong with my cookie? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What is wrong with my cookie?" Watch "What is wrong with my cookie?" New topic

What is wrong with my cookie?

Joe Wang

Joined: Sep 19, 2003
Posts: 3
Hi people,
I used following code to test Cookie:
public void doGet(... req, ... res)throws ...,..{
HttpCookie cookie = new Cookie("userName","someOne");
//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

Joined: Sep 16, 2000
Posts: 67
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,

I agree. Here's the link:
subject: What is wrong with my cookie?
It's not a secret anymore!