Skip to content

Instantly share code, notes, and snippets.

@andrewhowdencom
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewhowdencom/40a9821fe31a4889f285 to your computer and use it in GitHub Desktop.
Save andrewhowdencom/40a9821fe31a4889f285 to your computer and use it in GitHub Desktop.
Nginx alpha batch cookie bug
<?php
/**
* This works fine without the http2 directive. However, if the http2 directive is enabled, all cookies after
* the first cookie are lost.
*
* Working | listen: 443 ssl;
* Broken | listen: 443 ssl http2;
*/
// Set three cookies
setcookie('EXAMPLE_COOKIE', 'Example Value');
setcookie('ANOTHER_EXAMPLE_COOKIE', 'Another example value');
setcookie('A_THIRD_EXAMPLE_COOKIE', 'A third example value');
// Print the cookies on the next request.
var_dump($_COOKIE);
// HTTP2 Enabled: array(1) { ["EXAMPLE_COOKIE"]=> string(13) "Example Value" }
// HTTP2 Omitted: array(3) { ["EXAMPLE_COOKIE"]=> string(13) "Example Value" ["ANOTHER_EXAMPLE_COOKIE"]=> string(21) "Another example value" ["A_THIRD_EXAMPLE_COOKIE"]=> string(21) "A third example value" }
@andrewhowdencom
Copy link
Author

Worked around by manually using
fastcgi_set_param HTTP_COOKIE $http_cookie

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