tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Regan <>
Subject RE: Off topic:cookies nightmare!!!!!!!!
Date Mon, 29 Apr 2002 22:27:04 GMT
THAT WAS IT!!  Scott, thank you so much for the quick response, and thank
you Craig for the clarification!!  Happy Monday.

-----Original Message-----
From: Craig R. McClanahan []
Sent: Monday, April 29, 2002 2:49 PM
To: Tomcat Users List
Cc:; Struts Users (E-mail)
Subject: Re: Off topic:cookies nightmare!!!!!!!!

On Mon, 29 Apr 2002, pixel wrote:

> Date: Mon, 29 Apr 2002 17:42:13 -0400
> From: pixel <>
> Reply-To: Tomcat Users List <>
> To:
> Cc: Tomcat Users List <>,
>      "Struts Users (E-mail)" <>
> Subject: Re: Off topic:cookies nightmare!!!!!!!!
> John,
> I had a similar problem, which seem to be resovled by explicitly setting
> the path of the cookie to "/" before adding it to the response.
>     Cookie userCookie = new Cookie("U_ID", userId);
>     userCookie.setMaxAge(946080000);
>     userCookie.setPath("/");
>     httpResp.addCookie(userCookie);
> After reading the Servlet docs, it seems the behaviour for setting a
> cookie without first setting it's path is undefinded. I've found that
> with Tomcat, new Cookies use the current URL of the request instead of
> the "/" when a path is not specified. I also believe there may have been
> a few bugs with previous versions of Tomcat and Cookies which have been
> resolved with newer versions.

Setting the cookie path to "/" will cause this cookie to be sent back to
*all* web applications on your server, not just yours.  It is safer to set
the cookie path to return just to your web application:


> Hope this helps,
> ~Scott


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message