# Cookie from a http\_request\_t - howto?

**URL:** <https://www.ruby-forum.com/t/cookie-from-a-http-request-t-howto/189586>\
**Category:** NGINX\
**Created:** [June 3, 2010, 4:09pm UTC](https://www.ruby-forum.com/t/cookie-from-a-http-request-t-howto/189586 "2010-06-03T16:09:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rovar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7cd45c/32.png) [@rovar](https://www.ruby-forum.com/u/rovar)\
**Post date:** [June 3, 2010, 4:09pm UTC](https://www.ruby-forum.com/t/cookie-from-a-http-request-t-howto/189586/1 "2010-06-03T16:09:02Z")

</div>

Is there a simple example of how to read a cookie, or some other header  
value, like “Host” from an ngx\_http\_request\_t ?  
I see $variables discussed, but I’m not sure how to retrieve them.

I am guessing it has something to do with ngx\_http\_script\_compile/run,  
but I don’t fully understand the concept.  
Those functions seem to rely on a config file, but what if I’m not  
interested in configuring the variable, I just wish to  
retrieve Host or a specific Cookie from each request.

Also, at which stage in an upstream module process is the http request  
filled?  
Are they available in both init\__peer and get_\_peer?

Thanks,

Rick

Posted at Nginx Forum:

> **[Cookie from a http\_request\_t - howto?](https://forum.nginx.org/read.php?2,94077,94077#msg-94077)**
>
> Is there a simple example of how to read a cookie, or some other header value, like "Host" from an ngx\_http\_request\_t ? I see $variables discussed, but I'm not sure how to retrieve them. I am guessing it has something to do with...

---

<div class="post-metadata">

**Author:** ![rovar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7cd45c/32.png) [@rovar](https://www.ruby-forum.com/u/rovar)\
**Post date:** [June 3, 2010, 4:59pm UTC](https://www.ruby-forum.com/t/cookie-from-a-http-request-t-howto/189586/2 "2010-06-03T16:59:59Z")

</div>

I just found [http://wiki.nginx.org/HeadersManagement](http://wiki.nginx.org/HeadersManagement)

which has been a huge help. My remaining questions:

1. Also, at which stage in an upstream module process is the http  
request filled?  
Are they available in both init\__peer and get_\_peer?

2. Is there a helper function for finding a cookie of a specific name?

Thanks,  
Rick

Posted at Nginx Forum:

> **[Re: Cookie from a http\_request\_t - howto?](https://forum.nginx.org/read.php?2,94077,94097#msg-94097)**
>
> Is there a simple example of how to read a cookie, or some other header value, like "Host" from an ngx\_http\_request\_t ? I see $variables discussed, but I'm not sure how to retrieve them. I am guessing it has something to do with...
