Cannot log a cookie with a dash in the name

I am trying to log cookies but they have a dash in the name as such:

"Member-v1.0=$cookie_Member-v1.0"

My logs come through as:

Member-v1.0=--v1.0

Is there a work around?

I’ve tried wrapping the name in curly brackets and also using
underscores but get an error about an unmatched bracket or no value.
I’ve tried the following formats:

"Member-v1.0=${cookie_Member-v1.0}"

"Member-v1.0=$cookie_Member_v1.0"

"Member-v1.0=$cookie_Member_v1_0"

Any help would be greatly appreciated. I don’t want to have to move to
Apache :\

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223770,223770#msg-223770

On Mon, Mar 12, 2012 at 02:38:08PM -0400, Hates_ wrote:

I’ve tried wrapping the name in curly brackets and also using
Apache :
Currently, the names of nginx variables can be composed from
upper and lower English letters, digits and underscores. The
dash and dot characters are thus invalid.

Without patching the code, you should be able to log the entire
value of the “Cookie” request header field with the $http_cookie
variable. It can also be useful if you have cookies whose names
only differ in case as $cookie_ doesn’t differentiate
between upper and lower case:

http {
server {
location / {
return 200 ‘http_cookie=$http_cookie cookie_a=$cookie_a
cookie_A=$cookie_A\n’;
}
}
}

$ curl -b ‘a=a;A=A’ http://localhost:8000/test
http_cookie=a=a;A=A cookie_a=a cookie_A=a

On Monday 12 March 2012 22:38:08 Hates_ wrote:

I’ve tried wrapping the name in curly brackets and also using
Apache :\

The map module may help:

map $http_cookie $member_cookie {
default NONE;
^Member-v1.0=(?P[^;]+) $mc;
}

http://wiki.nginx.org/HttpMapModule

wbr, Valentin V. Bartenev

Thanks a lot, the mapping worked. I just had to escape the semi colon to
get it to work :slight_smile: Apache averted! :slight_smile:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223770,223790#msg-223790

On Tuesday 13 March 2012 00:57:17 Valentin V. Bartenev wrote:
[…]

The map module may help:

map $http_cookie $member_cookie {
default NONE;
^Member-v1.0=(?P[^;]+) $mc;
}

Oops… must be:

map $http_cookie $member_cookie {
    default '';
    ~Member-v1\.0=(?P<mc>[^;]+) $mc;
}

wbr, Valentin V. Bartenev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs