Reputation: 6011
I have Varnish set up to strip all cookies thus:
sub vcl_fetch {
unset beresp.http.Set-Cookie;
#etc
}
However, I want to set a cookie called first_visit
that I don't want Varnish to strip.
How do I do this?
Upvotes: 1
Views: 1269
Reputation: 1236
You can also strip cookies in plain VCL:
sub vcl_fetch {
# ...
if ( beresp.http.Set-Cookie
&& beresp.http.Set-Cookie == "first_visit=Y; path=/; domain=mydomain.tld"
) {
set beresp.http.first-visit = beresp.http.Set-Cookie;
unset beresp.http.Set-Cookie;
}
# ...
}
sub vcl_deliver {
# ...
if (resp.http.first-visit) {
set resp.http.Set-Cookie = resp.http.first-visit;
unset resp.http.first-visit;
}
# ...
}
Upvotes: 1