tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Barkon <>
Subject Is this correct behavior of cookies
Date Mon, 15 Nov 2010 19:25:08 GMT
I run development on Tomcat 6.0.29 and IE 8.
I need help to understand behavior of cookies. I created a new cookie and setup 
maxAge to 60 seconds running script setMaxAge(60). I expected this cookie to be 
persistent and to exist for 60 seconds. I ran this script to create the cookie
Cookie newCookie = new Cookie(request.getParameter("cookiename"), 

            That is what I found:
                        When I display maxAge by getMaxAge, I get -1,
not 60 as 
I expected
                        Cookie was actually alive for 60 seconds (as
it was 
supposed to be) while a browser was opened even though getMaxAge() returned -1. 

                        Cookie was not persistent. It means when I
closed all 
browsers and opened one again in less than 60 seconds, I found the cookie 
disappeared. I expected the cookie to be saved on my computer and exist after 
starting a browser within maximum age.
Please explain this behavior of cookie. 
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message