----------------------------------------------------------------
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.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)
    {
        System.err.println("In expireCookies");
        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];
            System.err.println("N: " + cookie.getName() + " V: " +
cookie.getValue());
            if (cookie.getName().equals("username"))
            {
                System.err.println("expiring...");
                // 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"))
            {
                System.err.println("expiring...");
                cookie.setMaxAge(0);
                System.err.println("max age: " + cookie.getMaxAge()); // prints a zero
                context.getResponse().addCookie(cookie);
            }
        }
    }

Am I doing something wrong here?

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