A problem with modifing r->headers_in.cookies

Srebrenko Šehić ssehic at gmail.com
Tue May 4 10:29:31 MSD 2010

On Tue, May 4, 2010 at 6:35 AM, Charles Tien <spirittf at gmail.com> wrote:
> No one can help me? :(
> On Sun, May 2, 2010 at 11:37 AM, tianfeng <spirittf at gmail.com> wrote:
>> I'm writing a module to add a cookie into r->headers_in.cookies, that the php-cgi server behind can get it from $_COOKIE. But there's a problem which I could not resolve.
>> If there's no cookie sent from client, I just create a new r->headers_in.cookies.elts to store my cookie for php-cgi behind as this:
>> ngx_table_elt_t* cookie = (ngx_table_elt_t*)ngx_pcalloc(r->pool, sizeof(ngx_table_elt_t));
>> cookie = (ngx_table_elt_t*)ngx_array_push(&r->headers_in.cookies);
>> Then I stroe my cookie to cookie, but the php-cgi can not get cookie from $_COOKIE.
>> However, if client already has cookie and send them to server, I can modify r->headers_in.cookies.elts to add my cookie to it, and the php-cgi behind can get my cookie from $_COOKIE.
>> My module is registed in NGX_HTTP_PREACCESS_PHASE.
>> I really don't know how to resolve it. Who can help me? Thank you very much!!

Can you try registering your handler at NGX_HTTP_REWRITE_PHASE?
Perhaps PREACCESS_PHASE is too early in hooks processing.

More information about the nginx-devel mailing list