tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <christopher.d.schu...@comcast.net>
Subject Re: Cookies.
Date Mon, 08 Dec 2003 15:52:45 GMT
Abdul,

> So, I have added the cookies value in servlet, and I can get the cookie
> value in jsp. When I work with the same browser fine working. But when close
> and open the new browser window I cant get the cookie values.
> 
> Setting cookie,
> 	res.addCookie(new Cookie("entID",eID));
> 	res.addCookie(new Cookie("lgnId",lgnId));

I checked the javadoc documentation for the Cookie class, and it doesn't 
seem to mention the default "life" of a Cookie object once sent to the 
browser. I'm inclined to think that the default is that it will live as 
long as the browser session does (especially because of your evidence).

Try this:

Cookie cookie = new Cookie("entId", eID);
cookie.setMaxAge(cookie_life_in_seconds);

res.addCookie(cookie);

cookie = new Cookie("ognId", ignId);
cookies.setMaxAge(cookie_life_in_seconds);

res.addCookie(cookie);

This is likely to extend the life of your cookies beyond the browser's 
session. Therefore, they will be sent in requests after the browser is 
restarted.

-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message