A problem with modifing r->headers_in.cookies

Charles Tien spirittf at gmail.com
Wed May 5 10:11:57 MSD 2010


I found the reson and resolve it. The php-cgi behind get $_SERVER data from
headers_in.headers.
Also I made some mistakes such as allocate memory for result that return
from ngx_array_push. (I read the function definition carefully then found
that the return value just had been allocated memory.)
Thank you all the same!

On Tue, May 4, 2010 at 2:29 PM, Srebrenko Šehić <ssehic at gmail.com> wrote:

> 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.
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20100505/ed7a606d/attachment.html>


More information about the nginx-devel mailing list