Z
Z
Zimaell2019-05-22 10:03:08
PHP
Zimaell, 2019-05-22 10:03:08

How to properly use cookies in phantomJS?

Entering the site through a phantom, he writes to me that cookies need to be enabled, I enabled them as written in the instructions

require '../vendor/autoload.php';
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
$client->getEngine()->setPath('../bin/phantomjs');
$request=$client->getMessageFactory()->createRequest();
$response=$client->getMessageFactory()->createResponse();
$client->getEngine()->addOption('--cookies-file=../cookie.txt');
$request->setMethod('GET');
$request->setUrl($url);
$content=$client->send($request,$response);

echo_var_dump($content);

as a result - firstly, such a line is written to the cookie
[General]
cookies="@Variant(\0\0\0\x7f\0\0\0\x16QList\0\0\0\0\x1\0\0\0\x1\0\0\0\ x63\x63sm-sid=378-9176816-8921664; expires=Tue, 18-Jun-2019 16:14:29 GMT; domain=www...........; path=/)"

and secondly, it hangs every other time that you need to overload the server.
Tell me how to use cookies correctly, the point is to create them initially, log in with them, and walk through the pages with these cookies ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question