title: What is the format for a cookie with multiple key value pairs using CURLOPT_COOKIE
body: <p>I'm scraping a site where, if I use my browser and click through the T.O.S., the page sets a cookie in my browser that looks like this:</p>
  
  <p><strong>Name</strong>    OnCoreWeb</p>
  
  <p><strong>Value</strong>   AutoLoadImages=-1&amp;ImageViewer=2&amp;DefaultNumberOfRows=10</p>
  
  <p>The cookie name is OnCoreWeb, but the value is an ampersand delimitted string of three key/value pairs.</p>
  
  <p>When I send the cookie in cURL, I construct it like this:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_COOKIE, "OnCoreWeb={AutoLoadImages=0&amp;ImageViewer=0&amp;DefaultNumberOfRows=50});
  </code></pre>
  
  <p>But when I output the headers, the Set-Cookie seems to append an extra value pair to the end of the first cookie, like this:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: private
  Transfer-Encoding: chunked
  Content-Type: text/html
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 2.0.50727
  Set-Cookie: OnCoreWeb={AutoLoadImages=0&amp;ImageViewer=0&amp;DefaultNumberOfRows=50}&amp;AutoLoadImages=-1; expires=Mon, 21-Aug-2017 00:36:44 GMT; path=/
  X-Powered-By: ASP.NET
  </code></pre>
  
  <p>Date: Sun, 21 Aug 2016 00:36:44 GMT</p>
  
  <p>You can see that in the Set-Cookie line, a <code>&amp;AutoLoadImages=-1;</code> is appended right after the closing <code>}</code>. This makes me think my cookie is somehow formatted wrong.</p>
  
  <p>As a control, I've commented out all the COOKIEJAR and COOKIEFILE lines, so that the only cookie setting is done via the CURLOPT_COOKIE property.</p>
  
  <p>As I think about this, I guess you could say the cookie VALUE is just a string, and the parsing is done server side, so wrapping the string in {} doesn't really magically make the string into an array. With this philosophy, I also tried wrapping the string in '' (double single-quotes), which also didn't make any difference. I guess I should try removing the {} or '' altogether, since the cookie value is merely a string, and the ampersands don't mean a thing client-side. Something server-side decides to parse the string using a "&amp;" as the delimiter.</p>
  
  <p>And magically, just like that, by removing the {} or '' wrapper around the cookie value string, the extra, superfluous <code>&amp;AutoLoadImages=-1;</code> disappeared.</p>
  
  <p>The new header appears correct, and looks like this:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: private
  Transfer-Encoding: chunked
  Content-Type: text/html
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 2.0.50727
  Set-Cookie: ASP.NET_SessionId=yqtxvba24xodegufrkoih355; path=/; HttpOnly
  Set-Cookie: OnCoreWeb=AutoLoadImages=0&amp;ImageViewer=0&amp;DefaultNumberOfRows=50; expires=Mon, 21-Aug-2017 17:35:12 GMT; path=/
  X-Powered-By: ASP.NET
  Date: Sun, 21 Aug 2016 17:35:12 GMT
  </code></pre>