<div dir="ltr"><div style="font-size:12.8px">Hi,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I have requirement to create own cookie  based on input  and wirte the that cookie in header.</div><div style="font-size:12.8px">whenever i need that i can read from header and use it.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">for example:-</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I have created my own cookie "thissomevalue" worte in header and later the same read from header.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Please check my code and let me know why i am not able to read the value from header.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Below code snippet to set header value in request header:-</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">ngx_table_elt_t *cookie;</div><div style="font-size:12.8px">cookie = ngx_list_push(&r->headers_in.headers);</div><div style="font-size:12.8px">cookie->lowcase_key = (u_char*) "cookie";</div><div style="font-size:12.8px">ngx_str_set(&cookie->key, "Cookie");</div><div style="font-size:12.8px">ngx_str_set(&cookie->value, "somevalue");</div><div style="font-size:12.8px">cookie->hash = ngx_crc32_long(cookie->lowcase_key, cookie->key.len);</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Below code snippet to read set value from header:-</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">ngx_http_core_main_conf_t   *clcf;</div><div style="font-size:12.8px">ngx_str_t                   *type;</div><div style="font-size:12.8px">ngx_uint_t                   key;</div><div style="font-size:12.8px">ngx_str_t    val = ngx_string("cookie");</div><div style="font-size:12.8px">clcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);</div><div style="font-size:12.8px">key= ngx_hash_key_lc(val.data, val.len);</div><div style="font-size:12.8px">type = ngx_hash_find(&clcf->headers_in_hash, key,  val.data, val.len);</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">if (type != NULL) </div><div style="font-size:12.8px">{</div><div style="font-size:12.8px">ngx_table_elt_t *test_val;</div><div style="font-size:12.8px">test_val= ngx_list_push(&r->headers_out.headers);</div><div style="font-size:12.8px">test_val->lowcase_key = (u_char*) "test_val";</div><div style="font-size:12.8px">ngx_str_set(&test_val->key, "Test_Val");</div><div style="font-size:12.8px">ngx_str_set(&test_val->value, type->data);</div><div style="font-size:12.8px">test_val->hash = ngx_crc32_long(test_val->lowcase_key, test_val->key.len);</div><div style="font-size:12.8px">}</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">curl response:-Test_val was accepting "somevalue"</div><div style="font-size:12.8px">HTTP/1.1 200 OK</div><div style="font-size:12.8px">Server: nginx/1.9.12</div><div style="font-size:12.8px">Date: Tue, 26 Apr 2016 19:13:40 GMT</div><div style="font-size:12.8px">Content-Type: text/plain</div><div style="font-size:12.8px">Content-Length: 34</div><div style="font-size:12.8px">Connection: keep-alive</div><div style="font-size:12.8px">Test_Val: Cookie </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Hello, This is Nginx test Module!</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks & Regards,</div><div style="font-size:12.8px">Pankaj Chaudhary</div></div>