----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Hello,

Env:            I have JDK1.1.7 (Linux, Blackdown), Jserv 1.1 Final and Apache
1.3.11.

Problem:        I'm trying to remove cookies by calling setMaxAge(0) on them.
                It doesn't appear to work for me - even after calling setMaxAge(0) I 
can
see the cookies with the following piece of javascript:

javascript:if(document.cookie.length<1){alert('No cookie for this
site.')}else{alert('Cookie for this site:'+document.cookie)}

Here is the complete method that I am trying to use to remove cookies. I use
WebMacro, Jon is very familiar with that one.

    /**
     *
     */
    private void expireCookies(WebContext context)
    {
        Cookie cookies[] = context.getRequest().getCookies();
        int cookieCount = cookies.length;
        String username = null;
        String password = null;

        for (int i=0; i<cookieCount; i++)
        {
            Cookie cookie = cookies[i];
            if (cookie.getName().equals("username"))
            {
                // expire the cookie
                cookie.setMaxAge(0);
                System.err.println("max age: " + cookie.getMaxAge());   // prints a 
zero
                context.getResponse().addCookie(cookie);
            }
            else if (cookie.getName().equals("password"))
            {
                cookie.setMaxAge(0);
                System.err.println("max age: " + cookie.getMaxAge()); // prints a zero
                context.getResponse().addCookie(cookie);
            }
        }
    }

Am I doing something wrong here?
Is there a better/an alternative way of removing cookies from Java?
I know that there is a newer version of JServ available, but I haven't seen
this issue mentioned in the ChangeLog.

Thanks,

Otis



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to