Ruslan Ermilov
March 12, 2012 04:42PM
On Mon, Mar 12, 2012 at 02:38:08PM -0400, Hates_ wrote:
> 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 :\

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_<name> 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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Cannot log a cookie with a dash in the name

Hates_ March 12, 2012 02:38PM

Re: Cannot log a cookie with a dash in the name

Ruslan Ermilov March 12, 2012 04:42PM

Re: Cannot log a cookie with a dash in the name

Valentin V. Bartenev March 12, 2012 05:00PM

Re: Cannot log a cookie with a dash in the name

Valentin V. Bartenev March 12, 2012 07:12PM

Re: Cannot log a cookie with a dash in the name

Hates_ March 13, 2012 05:27AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 233
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready