我正在构建基于Guzzle的客户端应用程序。我正在处理cookie处理。我试图使用Cookie plugin来实现它,但我无法实现它的工作。我的客户端应用程序是标准的Web应用程序,只要我使用相同的Guzzle对象,它看起来像是在工作,但是跨请求它不会发送正确的Cookie。我使用FileCookieJar
来存储Cookie。我怎样才能让cookie跨多个吸引对象?Guzzle cookies handling
// first request with login works fine
$cookiePlugin = new CookiePlugin(new FileCookieJar('/tmp/cookie-file'));
$client->addSubscriber($cookiePlugin);
$client->post('/login');
$client->get('/test/123.php?a=b');
// second request where I expect it working, but it's not...
$cookiePlugin = new CookiePlugin(new FileCookieJar('/tmp/cookie-file'));
$client->addSubscriber($cookiePlugin);
$client->get('/another-test/456');