Not according to this from the JSDK 2.1 documentation:

public void setMaxAge(int expiry)
Sets the maximum age of the cookie in seconds.
A positive value indicates that the cookie will expire after that many
seconds have passed. Note that the value is the maximum age when the cookie
will expire, not the cookie's current age.

A negative value means that the cookie is not stored persistently and will
be deleted when the Web browser exits. A zero value causes the cookie to be
deleted.

Parameters:
expiry - an integer specifying the maximum age of the cookie in seconds; if
negative, means the cookie is not stored; if zero, deletes the cookie

-- Marc

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Anamitra
Sent: Wednesday, November 03, 1999 1:49 PM
To: [EMAIL PROTECTED]
Subject: Re: [SERVLET-INTEREST] Deleting a cookie


setMaxAge(0) will not work as if u give the argument as 0 it will take the
default lifetime of the cookie ie the browsers instance. try setMaxAge(1).
Anamitra

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Marc
Tremblay
Sent: Wednesday, November 03, 1999 1:00 PM
To: [EMAIL PROTECTED]
Subject: Deleting a cookie


Does anyone know how to actually delete a cookie as setMaxAge(0) doesn't
seem to do anything at all in the code below.

public void service(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
        Cookie[] cookies = request.getCookies();

        PrintWriter out = response.getWriter();

        response.setContentType("text/html");

        out.println("<html><head><title>ClearCookies</title></head><body>");
        out.println("<h2>ClearCookies</h2><hr>");

        if (cookies != null) {
          for (int i = 0; i < cookies.length; i++) {
            out.println("Deleting: " + cookies[i].getName() + "<br>");
            cookies[i].setMaxAge(0);
          }

          out.println("<p>");
          out.println("<b>Your cookies have been deleted</b>");
        } else {
          out.println("<b>No cookies to delete</b>");
        }

        out.println("<hr></body></html>");

        out.close();
    }

Marc Tremblay
Web Programmer
EyeWire Inc.

___________________________________________________________________________
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

___________________________________________________________________________
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