title: Get a cookie with nodejs
body: <p>I am doing a Rest call in nodejs to get a report from JasperSoft Server.
  And
  I need to get a cookie to stay connected but I don't know how to do get it</p>
  
  <pre><code>var http = require('http');
  var options = {
    host: '127.0.0.1',
    port: 8080,
    path: '/jasperserver/rest/login?j_username=jasperadmin&amp;j_password=jasperadmin',
    method: 'POST'
  };
  
  http.request(options, function(res) {
  
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
  
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      console.log('BODY: ' + chunk);
  
    });
  }).end();
  </code></pre>
  
  <p>So it work but then I want to have acces to another link like 
  :localhost:8080/jasperserver/ressource/reports
  And I need the cookie to do that. How can I do to get it  ?</p>
  
  <p>For your informations,   console.log('HEADERS: ' + JSON.stringify(res.headers));
  display the cookie and the path and some other thing, so maybe i just have to parse it and get the cookie from there but I don't know how to do.</p>
  
  <p>Moreover, as I said I want to go to another link after being connected so can you also help me to set the cookie for another link ?</p>