>"Vaduvoiu Tiberiu" <[EMAIL PROTECTED]> wrote in message 
> >news:[EMAIL PROTECTED]
>Hi, guys. I'm running tomcat 6.0.3 and I'm having a problem with cookies in 
>jsp. After I set a cookie time using >cookie.setMaxAge(3600), when I run 
>cookie.getMaxAge() I get -1 instead of 3600(cookie is a object of type 
> >javax.servlet.http.Cookie). As I read on the internet about this issue I 
>understood that depending on application server >and configuration, cookies 
>can be generated automatically by servlet engine. In such case you can 
>control the max age trough configuration. As I understand, the reason why i 
>get -1 is because
>
>The server sets cookie values using this response header:
>Set-Cookie: NAME=VALUE; expires=DATE;
>path=PATH; domain=DOMAIN_NAME; secure
>
>while client sends cookies using this request header:
>Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2
>
>So to my understanding, I need to configure this somehow in tomcat. true? I 
>haven't found any articles related to this >though anywhere. Can someone 
>help me out with some info?? 10x a lot in advance
>
>

So, close :).  The problem, as you have stated, is that the browser can't 
send the 'expires' back to Tomcat according to the RFC, so Tomcat has 
absolutely no idea what it is when it gets the cookie back from the browser. 
Tomcat just sends the cookie back to the browser, and doesn't keep track of 
it otherwise.

Work-arounds include adding the date value to the cookie somehow, or when 
you create the cookie do something like:
    <% session.setAttribute("myCookieSetDate", new Date()); %>







---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to