I found the reson and resolve it. The php-cgi behind get $_SERVER data from headers_in.headers. <br>Also I made some mistakes such as allocate memory for result that return from ngx_array_push. (I read the<span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title=""> function definition carefully then found that the return value just had been allocated memory</span></span>.)<br>
Thank you all the same!<br><br><div class="gmail_quote">On Tue, May 4, 2010 at 2:29 PM, Srebrenko Šehić <span dir="ltr"><<a href="mailto:ssehic@gmail.com">ssehic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Tue, May 4, 2010 at 6:35 AM, Charles Tien <<a href="mailto:spirittf@gmail.com">spirittf@gmail.com</a>> wrote:<br>
><br>
> No one can help me? :(<br>
><br>
> On Sun, May 2, 2010 at 11:37 AM, tianfeng <<a href="mailto:spirittf@gmail.com">spirittf@gmail.com</a>> wrote:<br>
>><br>
>> 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.<br>
>> 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:<br>
>> ngx_table_elt_t* cookie = (ngx_table_elt_t*)ngx_pcalloc(r->pool, sizeof(ngx_table_elt_t));<br>
>> cookie = (ngx_table_elt_t*)ngx_array_push(&r->headers_in.cookies);<br>
>> Then I stroe my cookie to cookie, but the php-cgi can not get cookie from $_COOKIE.<br>
>> 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.<br>
>> My module is registed in NGX_HTTP_PREACCESS_PHASE.<br>
>> I really don't know how to resolve it. Who can help me? Thank you very much!!<br>
<br>
</div></div>Can you try registering your handler at NGX_HTTP_REWRITE_PHASE?<br>
Perhaps PREACCESS_PHASE is too early in hooks processing.<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://nginx.org/mailman/listinfo/nginx-devel</a><br>
</div></div></blockquote></div><br>