I'm trying to use node.js request to fetch a page from a webserver we use. I retrieve the cookies from the results of the previous request, and now trying send them to the profile page as request argument.
var request = require('request'),
fileCookieStore = require('tough-cookie-filestore');
var j = request.jar(new fileCookieStore("./cookie.json"));
var options = {
url : 'http://example.com/site/page.php?u=1234',
jar : j,
headers : {
"User-Agent":"user_agent"
}
};
request(options, function(err,res,body) {
if(err){
console.log(err);
return;
}
console.log('body');
});
cookie file looks like that:
[{
"domain": "www.example.com",
"expirationDate": 1482144640.897115,
"hostOnly": true,
"httpOnly": true,
"name": "password",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "8ff31b0edcf85b72b20469044dafc373",
"id": 1
},
{
"domain": "www.example.com",
"hostOnly": true,
"httpOnly": true,
"name": "sessionhash",
"path": "/",
"secure": false,
"session": true,
"storeId": "0",
"value": "13d0e4ff1bdeefbe118df4ad04c81a2e",
"id": 2
}]
and there's no luck. body in console log says that I'm still not logged in. How can I do that?