Remove only selected cookies from requests?

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

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

>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)

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

More information about the varnish-misc mailing list