2011年3月4日星期五

Extract individual cookie from multiple cookies

Hi,

Am developing an nginx module. I get multiple cookies in a http
request. I need to extract individual cookie from the multiple cookies
that I get. How do I achive this?

Is there an api to extract individual cookie?

From what I understand:

+ The cookies are present in request->headers_in as array

  cookies == request->headers_in->cookies

+ The length of this array is 1, even when we get multiple cookies.

+ Further investigation reveals that the element is a hash.

  cookies->elts is a hash.

  key   is cookie
  value is all cookies
  eg:
  key -> cookie
  value -> "cookie1=value1;cookie2=value2;cookie3=value3"

+ So will I need to parse the cookie string in "value" to extract
  individual cookies?

  Or is there a api that will help in extract individual cookies.

+ I cannot use ngx_http_parse_multi_header_lines() as I may not always
  know the name of the cookie (the cookie name may vary depending on
  id).
Thanks for your help.

~ s

没有评论:

发表评论