
SwooleHttpClient::post 메서드의 \'cookie\' 옵션을 사용하여 쿠키를 전송하는 방법은 다음과 같습니다.
#hostingforum.kr
php
$client = new SwooleHttpClient('example.com', 80);
$client->setCookie('key', 'value');
$client->post('/path', array('key' => 'value'), function ($frame) {
echo $frame->data;
});
$client->connect();
$client->send();
$client->close();
또는, 쿠키를 전송할 때마다 setCookie() 메서드를 호출할 수 있습니다.
#hostingforum.kr
php
$client = new SwooleHttpClient('example.com', 80);
$client->post('/path', array('key' => 'value'), function ($frame) {
echo $frame->data;
});
$client->connect();
$client->setCookie('key', 'newValue');
$client->send();
$client->close();
또한, 쿠키를 전송할 때는 setCookie() 메서드를 사용하는 것이 아니라, Cookie: header를 직접 설정하는 방법도 있습니다.
#hostingforum.kr
php
$client = new SwooleHttpClient('example.com', 80);
$client->setHeaders(array('Cookie' => 'key=value'));
$client->post('/path', array('key' => 'value'), function ($frame) {
echo $frame->data;
});
$client->connect();
$client->send();
$client->close();
2025-04-20 04:11