Answer the question
In order to leave comments, you need to log in
Why don't cookies received via Chrome work in Guzzle?
Hello!
In the browser I see a request to the server and it can be copied as curl. If I run it in the console, then I get the data,
and if I substitute Cookie in Guzzle, then I get an error that authorization is needed. Sample data:
curl 'https://test.ru' \
-H 'Connection: keep-alive' \
-H $'Cookie: WMONID=nRiQPgfdbrq; EUOBGSPNSESSIONID=pc1PrDd8VGeeVvONfQSptl7fIOxBla_tcfvJ6GqViXWeLBGojsP\u00211681227827\u00211177731283' \
--data-raw 'cmd=ServiceOrderModelSearchCmd&MODEL=SM-T295NZKASER&ASC_CODE=00062555555' \
$domain = 'test.ru';
$values = [
'WMONID' => 'nRiQPgfdbrq',
'EUOBGSPNSESSIONID'=>'pc1PrDd8VGeeVvONfQSptl7fIOxBla_tcfvJ6GqViXWeLBGojsP\u00211681227827\u00211177731283'
];
$cookieJar = \GuzzleHttp\Cookie\CookieJar::fromArray($values, $domain);
$client = new \GuzzleHttp\Client([
'base_uri' => 'https://test.ru',
]);
$response = $client->get('/endpoint',[
'cookies' => $cookieJar
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question