1

如何使用gotte但不将 cookie 发送回服务器?

我想这样做是因为服务器可以管理 URL 中的 sessionid。

4

2 回答 2

1

我最终直接使用guzzlebrowserkit,而不使用 goutte。Guzzle 让您选择管理或不管理 cookie http://guzzle.readthedocs.org/en/latest/quickstart.html#cookies

这解决了这个问题。

如果你真的喜欢 goutte,我想你也可以在每个请求之间删除 cookie。

于 2014-07-23T11:50:43.117 回答
-1

我看到的唯一方法是自己实例化 GuzzleClient 并将其传递给 Goutte 客户端。

像这样:

use Goutte\Client as GoutteClient;
use GuzzleHttp\Client as GuzzleClient;


$guzzleClient = new GuzzleClient(array('defaults' => array(
     'allow_redirects' => false,
     'cookies' => false
));
$client = new GoutteClient();
$client->setClient($guzzleClient);

$client->request('GET', 'http://example.org');
于 2014-07-23T12:16:34.467 回答