使用node.js幻像模块将cookie作为string添加到幻像页面

我幻影服务器运行,收到一个附加在头里面的cookie的请求。 我必须使用这个cookie,而从幻影打开一个页面。 更确切地说,我有一个string,我需要添加作为一个cookie,而打开一个页面。 我已经使用节点模块模型(npm install phantom)安装了幻影。 以下是我正在尝试的代码,但无法看到任何Cookie:

phantom.create(function(ph){ ph.createPage(function (page) { console.log(page); var cookieAdded = ph.addCookie({ 'name': 'OSF Cookie', 'value': req.headers.cookie, 'domain': req.headers.host }); console.log(cookieAdded); page.open(url, function (status) { if (status == 'success') { console.log("Success"); page.getCookies(function(cookie){ console.log(cookie); }); page.evaluate( function () { console.log(document.headers); return document.documentElement.outerHTML; }, function (content) { // console.log(content); res.send(content); console.log('RESPONSE SEND') ph.exit(); }); } else { console.log("Status Failed"); ph.exit(); } }) }); }); 

[编辑]下面是输出:

 http://localhost:5000/dashboard/ { url: 'http://localhost:5000/dashboard/' } osf=5540e22b8f6ac302b117a4cd.DWKdATsCvxskYqL-QfQYSjmYMvI { set: [Function], get: [Function], open: [Function], close: [Function], includeJs: [Function], sendEvent: [Function], release: [Function], uploadFile: [Function], goBack: [Function], goForward: [Function], reload: [Function], switchToFrame: [Function], switchToMainFrame: [Function], switchToParentFrame: [Function], switchToFocusedFrame: [Function], onConsoleMessage: [Function], onError: [Function], onResourceRequested: [Function], injectJs: [Function], evaluate: [Function], render: [Function], getContent: [Function], getCookies: [Function], renderBase64: [Function], setHeaders: [Function], setContent: [Function], setViewportSize: [Function], setPaperSize: [Function], setZoomFactor: [Function], setFileOnPicker: [Function], _evaluate: [Function], _onResourceRequested: [Function] } undefined Success [] RESPONSE SEND