title: Set Cookies into Mule HTTP Request
body: <p>I have requirement to set cookies into mules HTTP Request component. I verified different possibilities but no success. I am using Mule 3.9 CE. Any suggestion?</p>
  
  <p>I tried below (Use Cookies is enabled)</p>
  
  <ol>
  <li>Enabled User Cookies option for HTTP Request component  </li>
  <li>Tried to add cookies into the Header (Add cookies as header in component configuration)</li>
  <li>Set cookies using set property and used it as outbondproperties.</li>
  <li>Tried to add cookies using message transformer – same as 2 but different approach</li>
  <li>Tried to set HTTP Request metadata for cookies as String type</li>
  <li>Tried to retrieved cookies with  org.mule.transport.http.CookieHelper.parseCookiesAsAClient and then set as a property before 2nd call </li>
  </ol>
  
  <p>About flow:
  1.  Sends request with credential in it – just to get cookies (This part works in current mule process)
  2.  Send same request without credentials (this request uses cookies) and it returns the actual response.</p>
  
  <p>Please find below xml (subflow)</p>
  
  <pre><code>&lt;sub-flow name="test"&gt;
      &lt;invoke name="AcksRequest" object-ref="acksRequest" method="getAcksRequestWithCred" methodArguments="#[flowVars.txFile], ${user}, ${password}" doc:name="Invoke AcksRequest"/&gt;
      &lt;set-variable variableName="acksRequest" value="#[payload]" doc:name="Set Acks Request"/&gt;
      //This request sends request just for cookie
      &lt;http:request config-ref="HTTP_Request_Configuration" path="/test.asmx" method="POST" doc:name="HTTPS POST" metadata:id="ec75b200-28d1-49fc-bdcd-6883d6ba27c8"&gt;
          &lt;http:request-builder&gt;
              &lt;http:header headerName="Content-Type" value="text/xml"/&gt;
          &lt;/http:request-builder&gt;
      &lt;/http:request&gt;
  
      //Get cookies and set it as property
      &lt;logger message="Cookies----&amp;gt;  #[message.inboundProperties['set-cookie']]" level="INFO" doc:name="Logger"/&gt;
      &lt;set-property propertyName="Cookies" value="#[message.inboundProperties['set-cookie']]" doc:name="Property"/&gt;
      &lt;logger message="Outbond Property ----&amp;gt; #[message.outboundProperties.Cookies]" level="INFO" doc:name="Logger"/&gt;
  
      //Another call with cookie
      &lt;invoke name="AcksRequest1" object-ref="acksRequest" method="getAcksRequestWithoutCred" methodArguments="#[flowVars.txFile]" doc:name="Invoke AcksRequest"/&gt;
      &lt;http:request config-ref="HTTP_Request_Configuration" path="/test.asmx" method="POST" doc:name="HTTPS POST" metadata:id="4c78fe88-7b4c-47b9-bb9b-4a627207ae46"&gt;
          &lt;http:request-builder&gt;
              &lt;http:header headerName="Content-Type" value="text/xml"/&gt;
          &lt;/http:request-builder&gt;
      &lt;/http:request&gt;
  
      &lt;object-to-string-transformer doc:name="Object to String"/&gt;
      &lt;set-variable variableName="acks" value="#[payload]" doc:name="Set Acks Response"/&gt;        
  &lt;/sub-flow&gt;
  </code></pre>