Luc Saint-Elie wrote,
> But how to set the max age.. to the max age in
> situation one doesn't want the cookie to expire (in an
> intranet where the users are always the same)

I'm afraid there's no way to specify that a cookie
never expires ... that's true for Netscape cookies,
RFC2109 cookies, and the latest Internet Draft cookie
spec. You have to set a cookie Max-Age/Expires that's
a long way in the future.

> // Pose du cookie email
> Cookie emailCookie = new Cookie ("email", to);
> emailCookie.setPath("/");
> emailCookie.setMaxAge(Integer.MAX_VALUE);
> res.addCookie(emailCookie);
>
> Doesn't seem to work

Hmm ... this might be a bug in your servlet container.
Cookies set by servlets are, by default, version 0 (ie.
Netscape-style) which uses an Expires=<date> attribute
rather than version 1 (ie. RFC 2109+ style) which uses a
Max-Age=<seconds> attribute. It's possible that your
container doesn't handle the conversion from current
time+delta seconds to a Netscape cookie date correctly
for an offset as large as Integer.MAX_VALUE. Try using
something a bit smaller.

It's also conceivable that you've got legacy browsers
around that use the earliest Netscape cookie spec which
<gasp/> used a two-digit year number.

Incidently, be wary of trying to work around this by
doing setVersion(1). I seems that not all that many
browsers support 'new' cookies correctly yet ...
apparently only Lynx gets RFC 2109 right; and, in any
case, the new cookie spec is still in flux.

Cheers,


Miles

--
Miles Sabin                          Cromwell Media
Internet Systems Architect           5/6 Glenthorne Mews
+44 (0)181 410 2230                  London, W6 0LJ
[EMAIL PROTECTED]           England

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to