URGENT: cookies don't work with nginx (proxying to apache!)

Hi. nginx is proxying to apache. Everything works.

Except cookies. My php pages seem just not to be able to set cookies!

Is there any specific directive that I should watch out for?

Could proxy_cache stuff be interfering with it maybe?

My nginx.conf file is here:

My proxy.inc file is here:

Silly question: I am passing the header “Set Cookie”. Is there a header
for “Get Cookie”?

Posted at Nginx Forum:

pk899 Wrote:

maybe?

My nginx.conf file is here:
user nobody; worker_processes 4; worker_rlimit_nofile 40960; pid /var/run/nginx.pid; - 18331

My proxy.inc file is here:
proxy.inc file - a499c

Silly question: I am passing the header “Set
Cookie”. Is there a header for “Get Cookie”?

I ran some tests, and it seems one of the issues is that if cookies are
being set in a page, then the "header(location: xyz)’ command does not
work.

In apache, we got over this by setting output_buffering = on.

What’s the equivalent on nginx?

Thx

Posted at Nginx Forum:

On Sun, 2011-06-05 at 13:04 -0400, pk899 wrote:

I ran some tests, and it seems one of the issues is that if cookies are
being set in a page, then the "header(location: xyz)’ command does not
work.

In apache, we got over this by setting output_buffering = on.

What’s the equivalent on nginx?

That’s a PHP setting:

http://www.php.net/manual/en/outcontrol.configuration.php

Cliff

Cliff, thanks for this, but wouldn’t that redirect the page before
setting the cookie?

Posted at Nginx Forum:

On Sun, 2011-06-05 at 13:04 -0400, pk899 wrote:

I ran some tests, and it seems one of the issues is that if cookies are
being set in a page, then the "header(location: xyz)’ command does not
work.

Try setting the location header before setting the cookie:

header(‘Location: …’);
setcookie(‘mycookie’, …);

Cliff

On Sun, 2011-06-05 at 14:19 -0400, pk899 wrote:

Cliff, thanks for this, but wouldn’t that redirect the page before
setting the cookie?

No, it just sets a header. I don’t believe header order should matter
in any case, so I expect this is some PHP issue with outputting headers.

Cliff