如何使用gotte但不将 cookie 发送回服务器?
我想这样做是因为服务器可以管理 URL 中的 sessionid。
我最终直接使用guzzle和browserkit,而不使用 goutte。Guzzle 让您选择管理或不管理 cookie http://guzzle.readthedocs.org/en/latest/quickstart.html#cookies。
这解决了这个问题。
如果你真的喜欢 goutte,我想你也可以在每个请求之间删除 cookie。
我看到的唯一方法是自己实例化 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');