Mantis - Quercus
Viewing Issue Advanced Details
4767 block always 09-18-11 15:09 09-21-11 08:37
new 4.0.14  
0004767: Array cookies are not read properly
Reading a cookie like name[index] doesn't work in Resin/Quercus.
When sending a cookie name[index] instead of being processed and put into array variable using index to set the value, a variable named 'name[index]' is set the value. It should behave as described in [^] and [^] (about reading cookies). It seems that the place where the functionality is missed is [^] method, which doesn't distinguish cookies whose names contain square brackets, so it does not treat them as arrays, but just as normal (flat) variables.
In fact it happens in 4.0.19+
 issue0004767.patch [^] (2,818 bytes) 09-21-11 08:37

09-18-11 15:13   
You might check this behaviour comparing Resin/Quercus and normal/standard PHP by using this PHP script on server-side:

$arrayIdx = 31337;
if(array_key_exists($name, $_COOKIE) && array_key_exists($arrayIdx, $_COOKIE[$name]))
  echo "behaving like normal PHP";
if(array_key_exists($name.'['.$arrayIdx.']', $_COOKIE))
  echo "behaving like Resin";

and sending HTTP request to this script and setting required cookie - as in this example:

private static final String COOKIE_NAME = "ARRAY-COOKIE-TEST";
private static final int ARRAY_INDEX = 31337;
private static final String COOKIE_VALUE = "test-value";

public void testTracker() throws Exception {
  HttpClientParams params = new HttpClientParams();
  HttpClient client = new HttpClient(params);
  HostConfiguration config = new HostConfiguration();

  HttpHost host = new HttpHost("", 80,

  HttpMethod method = new GetMethod("/array-cookie-test.php");
  method.addRequestHeader("Cookie", COOKIE_NAME + "[" + ARRAY_INDEX
    + "]=" + COOKIE_VALUE + "; expires=Fri, 29-Sep-2012 15:03:21 GMT; path=/");
09-19-11 14:17   
One point to note - multidimensional arrays should be supported - [^] -> Storing Arrays
09-20-11 11:46   
Another update on cookies spec version and their interoperability between Java and other platforms/languages (I might be good to be aware of it - as Resin/Quercus is to be interoperable between Java and PHP worlds) - especially comments in: [^] [^]

resulting in org.glassfish.web.rfc2109_cookie_names_enforced settings property in different implementations of javax.servlet.http.Cookie

Worth mentioning is also a rather juicy discussion around Tomcat's approach to cookies in: [^]

09-21-11 08:37   
Please find attached a patch which fixes the described issue. The patch has been made against the trunk version. I might be missing formatter settings in Eclipse (as the formatter_profile=_caucho in .settings doesn't seem to be available in your SVN's trunk), so I would need to ask you to reformat the code with your formatter settings just after applying the patch.