title: How to set HTTP cookies with Twilio and Node?
body: <p>I'm trying to use cookies to track SMS conversations with my node app, but they never seem to get set correctly. At least, when I retrieve them in the next text from the user, they're still null.</p>
  
  <p>I have this function where it sets a cookie and sends a response to the user:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function requestLocation (res, resend) {
      var locationXml = "";
      ...
  
      var responseText = "";
      ...
      
      var response = new twilio.TwimlResponse();
      response.sms(responseText);
      res.cookie('rideStage', rideStages.SENT_REQUEST);
      res.send(response.toString(), {
          'Content-Type':'text/xml'
      }, 200);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But when I receive the next message from that user, "request.cookies.rideStage" is always null. I've also tried replacing</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>res.cookie('rideStage', rideStages.SENT_REQUEST);
  res.send(response.toString(), {
          'Content-Type':'text/xml'
      }, 200);</code></pre>
  </div>
  </div>
  </p>
  
  <p>with</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>res.send(response.toString(), {
          'Set-Cookie':'rideStage='+rideStages.SENT_REQUEST,
          'Content-Type':'text/xml'
      }, 200);</code></pre>
  </div>
  </div>
  </p>
  
  <p>but, request.cookies.rideStage is still null.</p>