This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes kookie.getMAxAge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "kookie.getMAxAge" Watch "kookie.getMAxAge" New topic


Bruno Korcinski

Joined: Jun 03, 2003
Posts: 16
Hi guys,

I have set kookie.setMaxAge(3600)in servlet SetCookie;

I read back kookies in other servlet ShowCookie...kookie was there but I have expected some int value in seconds kookie.getMaxAge()but I got -1.
Is this value reset to -1 so I canot check how much time for kookie was sets before?


myCookie Name myCookie Value MaxAge
Persistent-Cookie-0 Cookie-Value-P0 null null -1
Persistent-Cookie-1 Cookie-Value-P1 null null -1
Persistent-Cookie-2 Cookie-Value-P2 null null -1

I took out special char...from html and ..ookie =Kookie for posting on this page

Kookie[] cookies = request.getKookies();
Kookie kookie;
for(int i=0; i<kookies.length; i++) {
kookie = kookies[i];
out.println("TR\n" +
" TD" + kookie.getName() + "\n" +
" <D" + kookie.getValue()+ "\n" +
" TD" + kookie.getDomain() + "\n" +
" <D" + kookie.getPath() + "\n" +
" <D" + kookie.getMaxAge());
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: kookie.getMAxAge