W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 1997

Multiple cookies?

From: Anselm Baird_Smith <abaird@www43.inria.fr>
Date: Thu, 6 Feb 1997 23:01:03 +0100 (MET)
Message-Id: <199702062201.XAA25705@www43.inria.fr>
To: bpm@techapp.com
Cc: www-jigsaw@w3.org

 > Anselm, here is a simple cgi script that tries to set multiple
 > cookies.  Only the last one is set (test2=4321).  Is this a bug?  The
 > NCSA & Apache servers work fine with this script.  I tried to dig
 > through the code, but got lost.  I can't tell if the request is not
 > getting all of the cookies, or is not parsing the header correctly.
 > 

Go it, the CGI resource doesn't accumulate header values, instead it
override any previous header value with the new one. They are two ways
for you to fix that:

a) Modify w3c.jigsaw.forms.CgiResource in the following way:

    public void notifyHeader(String name, byte buf[], int off, int len)
        throws MimeParserException
    {
        if ( name.equalsIgnoreCase("status") ) {
            status = new String(buf, 0, off, len);
        } else if ( name.equalsIgnoreCase("location") ) {
            location = new String(buf, 0, off, len);
        } else {
            String extraval =  new String(buf, 0, off, len);
            if ( headers == null ) {
                headers = new Hashtable(11);
            } else {
                String val = (String) headers.get(name.toLowerCase());
                if ( val != null )
                    extraval = val + "," + extraval;
            }
            headers.put(name.toLowerCase(), extraval);
        }
    }

    Which is the real fix (included in next public release)

b) Modify your script to make it emit both cookies under the same
Set-Cookie header

Anselm.
Received on Thursday, 6 February 1997 17:01:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:26 GMT