Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http::$cookies do not handle duplicate calls correctly #89

Open
JJCLane opened this issue Dec 17, 2024 · 1 comment
Open

Http::$cookies do not handle duplicate calls correctly #89

JJCLane opened this issue Dec 17, 2024 · 1 comment

Comments

@JJCLane
Copy link

JJCLane commented Dec 17, 2024

Great job on AdapterMan so far! I've been experimenting with this and trying to narrow down some unusual behaviour.

Currently the handling of cookies appends any calls of setCookie to the static $cookies array, but this leads to a situation where multiple calls with the same name ends up returning multiple Set-cookie headers which differs from normal PHP execution.

E.g.

setCookie('myCookie', 1);
setCookie('myCookie', 2);

Normal PHP response

Set-Cookie: myCookie=2; path=/; HttpOnly; SameSite=Strict

AdapterMan

Set-Cookie: myCookie=1; path=/; HttpOnly; SameSite=Strict
Set-Cookie: myCookie=2; path=/; HttpOnly; SameSite=Strict

Relevant code:

static::$cookies[] = 'Set-Cookie: ' . $name . '=' . \rawurlencode($value)
static::$cookies[] = $content;

@joanhey
Copy link
Owner

joanhey commented Dec 18, 2024

Good catch !!
I'll try to fix it this Christmas and add a test.

But the final solution is to use the original php functions, we send a PR to php-src. php/php-src#16145
When this PR is merged we don't need to disable functions, and use directly the php functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants