Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

only last cookie is sent #16

Open
meaninglessidentifier opened this issue Dec 16, 2016 · 1 comment
Open

only last cookie is sent #16

meaninglessidentifier opened this issue Dec 16, 2016 · 1 comment

Comments

@meaninglessidentifier
Copy link

meaninglessidentifier commented Dec 16, 2016

if php's setcookie is called multiple times per response, only the last cookie will be included in the response.

for example, the response from the following php code will include only the "bbb" cookie.

<?php
setcookie("aaa", "xxx");
setcookie("bbb", "zzz");

for contrast, the following express code works as expected.

var express = require('express');
var app = express();
app.get('/', function(req, res){
  res.cookie('aaa', 'zzz');
  res.cookie('bbb', 'xxx');
  res.send('z');
});
app.listen(9090);

this prevents wordpress from functioning as its authentication process sets multiple cookies in a single request. (cf wp_set_auth_cookie in wp-includes/pluggable.php.)

i have tried using the version of node-php currently available from npm as well as the current head on github with the same results. am i doing something wrong?

edit: in case it's relevant, here is the code that i am using to start the server:

var express = require('express');
var php = require("node-php");
var app = express();
app.use("/", php.cgi(__dirname+"/cookietest"));
app.listen(9090);

edit2: and just in case this is relevant...

$ php-cgi --version
PHP 5.5.9-1ubuntu4.20 (cgi-fcgi) (built: Oct  3 2016 13:02:14)
...

edit3: i've also confirmed that the above php code works as expected when served by invoking the php executable as follows

$ php -S 127.0.0.1:9090 -t ./cookietest/
@addyh
Copy link
Contributor

addyh commented Sep 1, 2017

Fixed with pull request #19

mkschreder added a commit that referenced this issue Mar 19, 2020
Fixes issue #16 (multiple Set-Cookie headers)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants