Welcome! Log In Create A New Profile

Advanced

Re: How to change cookie header in a filter?

Maxim Dounin
March 20, 2013 04:40AM
Hello!

On Tue, Mar 19, 2013 at 11:50:43AM -0700, Cool wrote:

> Thanks Maxim, I got what you mean.
>
> Since I'm using fastCGI so I put something like this:
>
> fastcgi_param HTTP_COOKIE "$http_cookie; mycookie=$cookie_note";
>
> (I populated cookie_note in my filter already, this was done for
> logging purpose thus it is just a reuse of existing facility)
>
> More problems come with this solution:
>
> 1. it seems fastcgi_param called before my filter so $cookie_note
> always got empty, and

You shouldn't rely on your filter already executed, and should
instead register a variable handler which does the actual work.
This way it will work at any time.

> 2. it seems fastcgi_param could not be used in a if directive so I
> end up with change the cookie header even the mycookie is presented
> in user's request, thus

If there are conditions when you should not add a cookie I would
recommend you implementing a variable with full Cookie header you
want to pass, e.g.

fastcgi_param HTTP_COOKIE $my_new_cookie;

This way you may implement arbitrary conditions you want in your
module. (You may also construct the variable using if/set/map/etc, but
doing appropriate tests in your module would be less error prone.)

--
Maxim Dounin
http://nginx.org/en/donation.html

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

How to change cookie header in a filter?

Cool March 18, 2013 07:26PM

Re: How to change cookie header in a filter?

Maxim Dounin March 19, 2013 09:06AM

Re: How to change cookie header in a filter?

Cool March 19, 2013 02:52PM

Re: How to change cookie header in a filter?

Maxim Dounin March 20, 2013 04:40AM

Re: How to change cookie header in a filter?

Cool March 21, 2013 12:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 141
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