Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

How to set cookies? #178

Open
muleyo opened this issue Apr 23, 2022 · 1 comment
Open

How to set cookies? #178

muleyo opened this issue Apr 23, 2022 · 1 comment

Comments

@muleyo
Copy link

muleyo commented Apr 23, 2022

Hello,

I'm trying to set cookies with $page->setCookies(file_get_contents("cookies.json")); but unfortunately, I get an error:

Fatal error: Uncaught Nesk\Rialto\Exceptions\Node\FatalException: Protocol error (Network.deleteCookies): Invalid parameters Failed to deserialize params.name - BINDINGS: mandatory field missing at position 11580 in /var/www/panel/vendor/nesk/rialto/src/ProcessSupervisor.php:307 Stack trace: #0 /var/www/panel/vendor/nesk/rialto/src/ProcessSupervisor.php(387): Nesk\Rialto\ProcessSupervisor->checkProcessStatus() #1 /var/www/panel/vendor/nesk/rialto/src/Traits/CommunicatesWithProcessSupervisor.php(84): Nesk\Rialto\ProcessSupervisor->executeInstruction(Object(Nesk\Rialto\Instruction)) #2 /var/www/panel/vendor/nesk/rialto/src/Traits/CommunicatesWithProcessSupervisor.php(100): Nesk\Rialto\Data\BasicResource->proxyAction('call', 'setCookie', Array) #3 /var/www/panel/test.php(27): Nesk\Rialto\Data\BasicResource->__call('setCookie', Array) #4 {main} thrown in /var/www/panel/vendor/nesk/rialto/src/ProcessSupervisor.php on line 307

The same happens if I try $page->setCookies(json_decode(file_get_contents("cookies.json")));

@sundayj-1213
Copy link

sundayj-1213 commented Apr 27, 2022

You are passing a string to the function, convert the string to an array, then it should work

$cookies = json_decode(file_get_contents("cookies.json"));
$page->setCookies(...$cookies);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants