title: how to using cookie with request (request , tough-cookie , node.js)
body: <p>I'm wondering to know how to using cookie with <a href="https://github.com/mikeal/request" rel="noreferrer">request</a> (<a href="https://github.com/mikeal/request" rel="noreferrer">https://github.com/mikeal/request</a>)</p>
  
  <p>I need to set a cookie which able to be fetched for every sub domains from request, </p>
  
  <p>something like </p>
  
  <blockquote>
    <p>*.examples.com</p>
  </blockquote>
  
  <p>and the path is for every page, something like</p>
  
  <blockquote>
    <p>/</p>
  </blockquote>
  
  <p>then server-side able to fetch the data from cookie correctly, something like </p>
  
  <blockquote>
    <p>test=1234</p>
  </blockquote>
  
  <p>I found the cookies which setup from response was working fine,</p>
  
  <p>I added a custom jar to save the cookies, something like</p>
  
  <pre><code>var theJar = request.jar();
  
  var theRequest = request.defaults({
              headers: { 
                  'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36' 
              } 
            , jar: theJar
          });
  </code></pre>
  
  <p>but the cookies which I setup from request, only able to be fetched in same domain,</p>
  
  <p>and I can't find a method to setup cookie in more options</p>
  
  <p>for now if I want one cookie which able to be fetched in three sub domains,</p>
  
  <p>I have to setup like this way:</p>
  
  <pre><code>theJar.setCookie('test=1234', 'http://www.examples.com/', {"ignoreError":true});
  
  theJar.setCookie('test=1234', 'http://member.examples.com/', {"ignoreError":true});
  
  theJar.setCookie('test=1234', 'http://api.examples.com/', {"ignoreError":true});
  </code></pre>
  
  <blockquote>
    <p><strong>Is here any advance ways to setup a cookie from request,</strong></p>
    
    <p><strong>made it able to be fetched in every sub domains ???</strong></p>
  </blockquote>