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:
http://tinypaste.com/18331

My proxy.inc file is here:
http://tinypaste.com/a499c

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

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,204130,204130#msg-204130

pk899 Wrote:

maybe?

My nginx.conf file is here:
http://tinypaste.com/18331

My proxy.inc file is here:
http://tinypaste.com/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:
http://forum.nginx.org/read.php?2,204130,204140#msg-204140

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:
http://forum.nginx.org/read.php?2,204130,204158#msg-204158

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs