Problem when several "Cookie" http header was sent to the server #72

mageekguy opened this Issue Jul 19, 2012 · 5 comments


None yet
4 participants

When i'am using the following code as client :

use Goutte\Client;
$goutte = new Client();
$guzzleRequest = $goutte->getClient()->createRequest('get', 'http://localhost/cookies.php');
$guzzleRequest->addCookie('foo', 'FOO');
$guzzleRequest->addCookie('bar', 'BAR');

And the following code on the server :

file_put_contents('/path/to/cookies.log', ob_get_clean());

I have in the /path/to/cookies.log file the following contents :

array(1) {
  'foo' =>
  string(12) "FOO, bar=BAR"

I'm using PHP 5.3.14 with XDebug 2.2.0 on Ubuntu.
Goutte is installed in Symfony 2.1 with the following composer.json :

    "require": {
        "php": ">=5.3.6",
        "symfony/symfony": "dev-master",
        "symfony/assetic-bundle": "dev-master",
        "symfony/swiftmailer-bundle": "dev-master",
        "symfony/monolog-bundle": "dev-master",
        "symfony/twig-bundle": "2.1.*@stable",
        "symfony/yaml": "dev-master",
        "symfony/config": "dev-master",
        "symfony/translation": "dev-master",
        "symfony/config": "dev-master",
        "sensio/distribution-bundle": "dev-master",
        "sensio/framework-extra-bundle": "dev-master",
        "sensio/generator-bundle": "dev-master",
        "doctrine/orm": "dev-master",
        "doctrine/doctrine-bundle": "dev-master",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "twig/extensions": "dev-master",
        "jms/security-extra-bundle": "1.1.*",
        "stof/doctrine-extensions-bundle": "dev-master",
        "whiteoctober/breadcrumbs-bundle": "2.1.*-dev",
        "behat/behat": "2.4.*@stable",
        "behat/mink": "1.4.*@stable",
        "behat/gherkin": ">=2.2.1",
        "behat/mink-extension": "dev-master",
        "behat/mink-goutte-driver": "*",
        "behat/mink-sahi-driver": "*",
        "behat/mink-browserkit-driver":  "*",
        "behat/mink-selenium2-driver":   "*",
        "behat/symfony2-extension": "dev-master",
        "mageekguy/atoum": "dev-master"
    "scripts": {
        "post-install-cmd": [
        "post-update-cmd": [
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "symlink"
    "autoload": {
        "psr-0": {
            "Webloc": "src/"
    "config": {
        "bin-dir": "bin"

mtdowling commented Aug 29, 2012

I was not able to reproduce this issue.

Can you turn on verbose curl output to see if the Cookie header is being sent correctly?

$guzzleRequest->getCurlOptions()->set(CURLOPT_VERBOSE, true);

Can you test using different cookie values? Maybe the foo=FOO is tripping up PHP.


mtdowling commented Aug 29, 2012

It looks like it's being sent over the wire correctly (using the latest and even using the previous version in Goutte 2.8.4):

* Connected to ( port 8124 (#0)
> GET / HTTP/1.1
Accept: */*
Accept-Encoding: deflate, gzip
User-Agent: Guzzle/2.8.4 curl/7.21.4 PHP/5.3.10
Cookie: foo=FOO; bar=BAR

Can you confirm?

gondo commented Jan 15, 2014

why do you use Goutte in this case, why not directly Guzzle? (thats what you are essentially doing)
if your answer is that you use Goutte to work with response, than my question is how? (some code example would be the best, ta)

samvdb commented Aug 13, 2014

I can confirm this issue when using Guzzle directly, it appears some servers dont accept cookies in multiple headers.

I can see:
Via:1.1 varnish
And apache


mtdowling commented Aug 13, 2014

@samvdb Are you saying your server doesn't handle Cookie headers where multiple cookie values are in the same header line (e.g., foo=FOO; bar=BAR)? If so, that would imply that something is broken server side because that's how web browsers sends the Cookie header. Maybe a verbose curl output would help here, but Guzzle shouldn't ever send multiple header lines for the Cookie header (they'll be combined onto the same line).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment