| Author |
What is wrong with my cookie?
|
Joe Wang
Greenhorn
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"); 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
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, Ciao, GSS
|
SCJP, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
|
 |
 |
|
|
subject: What is wrong with my cookie?
|
|
|