Multiple cookies?

Anselm Baird writes:
 |
 | > 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);
 |        }
 |    }

Well, I tried this, but it merged the two cookies.  So I changed

extraval = val + "," + extraval;

to be

extraval = val + ";" + extraval;

Then all I got was the FIRST cookie.  Oh well, I guess that I need to
go and look at what the header really looks like.  It just seems to not
ADD to the header.

-- 
Brian Millett                    
Technology Applications Inc.     "Heaven can not exist,
(314) 530-1981                          If the family is not eternal"
bpm@techapp.com                   F. Ballard Washburn

Received on Thursday, 6 February 1997 20:12:18 UTC