Remove only selected cookies from requests?

Espen Braastad espen at linpro.no
Fri Oct 17 00:18:51 CEST 2008


On 2008-10-07 15:49, Espen Braastad <espen at linpro.no> wrote:

>Hi,
>
>The question:
>Is it possible to match cookie names in each request to a regexp, and
>remove only specified cookies? Other cookies must not be removed.

The answer:
Yes. The following two lines in vcl_recv will remove the cookie named
baz only:

sub vcl_recv {
# Is it the first one?
set req.http.cookie = regsub(req.http.cookie, "baz=[^;]+(; )?", "");

# Or perhaps one in the middle or the last one?
set req.http.cookie = regsub(req.http.cookie, "(; )?baz=[^;]+", "");
}


(Thank you, Tollef)

mvh
Espen Braastad,
+47 938 60 737
espen at linpro.no
Linpro AS - Ledende på Linux






More information about the varnish-misc mailing list