Skip to content

How to add cookie? #118

@herlon214

Description

@herlon214

My code:

var ph = require('phantom');

ph.create(function(err, phantom) {
  console.log('Loading a web page');
  phantom.addCookie({
    "name": "PHPSESSID",
    "value": "9lrinitbsot9lvf7d7peej1456",
    'domain': '.google.com'
  });

  phantom.createPage(function(page) {
    var url = 'http://google.com';
    page.open(url, function (status) {
      page.render('image.png');
      // var link = page.evaluate(function() {
      //   return document.getElementById("download").getAttribute('href');
      // });
    });
  });

},{
  dnodeOpts: {
    weak: false
  }
});

It's returning:

c:\Users\herlon214\dev\nodejs\foo\generatorjs\index.js:5
  phantom.addCookie({
         ^
TypeError: Cannot read property 'addCookie' of undefined
    at ph.create.dnodeOpts.weak (c:\Users\herlon214\dev\nodejs\foo\gener
atorjs\index.js:5:10)
    at D.<anonymous> (c:\Users\herlon214\dev\nodejs\foo\generatorjs\node
_modules\phantom\phantom.js:164:45)
    at D.emit (events.js:110:17)
    at Proto.<anonymous> (c:\Users\herlon214\dev\nodejs\foo\generatorjs\
node_modules\phantom\node_modules\dnode\lib\dnode.js:53:14)
    at Proto.emit (events.js:107:17)
    at Proto.handleMethods (c:\Users\herlon214\dev\nodejs\foo\generatorj
s\node_modules\phantom\node_modules\dnode\node_modules\dnode-protocol\index.js:1
18:10)
    at Proto.handle (c:\Users\herlon214\dev\nodejs\foo\generatorjs\node_
modules\phantom\node_modules\dnode\node_modules\dnode-protocol\index.js:77:14)
    at D.dnode.handle (c:\Users\herlon214\dev\nodejs\foo\generatorjs\nod
e_modules\phantom\node_modules\dnode\lib\dnode.js:140:21)
    at D.dnode.write (c:\Users\herlon214\dev\nodejs\foo\generatorjs\node
_modules\phantom\node_modules\dnode\lib\dnode.js:128:22)
    at SockJSConnection.ondata (stream.js:51:26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions