On Tue, 25 Sep 2001, Hunter Hillegas wrote:

> Date: Tue, 25 Sep 2001 11:52:16 -0700
> From: Hunter Hillegas <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: Tomcat User List <[EMAIL PROTECTED]>
> Subject: Tomcat 4.0 Bug Status
>
> Anyone know the status of this bug:
>
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3799
>
> Basically, setting a cookie with a null value throws an exception... This
> causes many webapps like Jive Forums to just not work...
>
> Hunter
>
>

Unfortunately, the bug report is incorrect, and applications that rely on
the proposed behavior are broken.

The proper way to delete a cookie is to set the maximum age to zero before
sending the cookie:

  Cookie cookie = new Cookie("foo", "arbitrary value");
  cookie.setMaxAge(0);
  response.addCookie(cookie);

See the Javadocs for javax.servlet.http.Cookie.setMaxAge() for details.

Even if setting the value to null did not cause an NPE, it would not
delete your cookie.


Craig


Reply via email to