You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Igor Barkon <ig...@att.net> on 2010/11/15 20:25:08 UTC

Is this correct behavior of cookies

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"), 
request.getParameter("cookievalue"));         

 
                                    newCookie.setMaxAge(60);
                                    response.addCookie(newCookie);
            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. 

Re: Is this correct behavior of cookies

Posted by Mark Thomas <ma...@apache.org>.
On 15/11/2010 19:25, Igor Barkon wrote:
> I run development on Tomcat 6.0.29 and IE 8.

Try testing with a browser that implements RFC2109. Unless there have
been some major improvements since I last tested IE8, it doesn't even
come close.

I'd also recommend using a tool that lets you examine HTTP request and
response headers. Most browsers have at least one plug-in for this.

Mark

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