You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Kedar Hirve <kh...@evincible.com> on 2001/07/19 17:21:43 UTC

Clearing, or even setting cookies that already exist

Hmm, I'm honestly not positive whether this is a problem with Tomcat, or
something more basic than that...

I've got this servlet, let's say I'm just testing cookie-setting and
-clearing capabilities. When the servlet is invoked from a form, I set two
cookies, with -1 MaxAge. Later, if I call it alone, not from a form, it's
set to clear the cookies. That is, set their MaxAge to 0.

When clearing a cookie, do I create a new cookie object of the name I want
to clear, set its max age to 0, and add it to the response? I tried this,
but it wouldn't clear the cookie. In fact, it doesn't look like it adds a
new cookie at all. I'm doing all my cookie-adding before I call the
getWriter method of my response, or setting any other headers.

Furthermore, even though I setDomain on the cookies before I add them
initially, I get null when I getDomain on the cookies later.

I'm not sure if this is a problem with Tomcat or not, and I hope I'm not on
the wrong list to post this, but it may be a bug in Tomcat?

Thanks in advance,
-KSH