log "Original Cookie header: " req.http.Cookie;

# Create a new header to store the filtered cookies
# cookies (key=value) are now separated with ","
# due to Fastly Varnish implementation
set req.http.X-Filtered-Cookie:name2 = req.http.Cookie:name2;
set req.http.X-Filtered-Cookie:name3 = req.http.Cookie:name3;
set req.http.X-Filtered-Cookie:name6 = req.http.Cookie:name6;

log "req.http.X-Filtered-Cookie: " req.http.X-Filtered-Cookie;

# Clear the original Cookie header
unset req.http.Cookie;

# Overwrite the incoming Cookie header with the filtered values:
# cookies (key=value) are separated with ";"
# Fastly changes the delimiter only when assinging values
# for Cookie/Set-Cookie header using the ":" operator
set req.http.Cookie:name2 = req.http.X-Filtered-Cookie:name2;
set req.http.Cookie:name3 = req.http.X-Filtered-Cookie:name3;
set req.http.Cookie:name6 = req.http.X-Filtered-Cookie:name6;

# Remove the filtering header we used for tidiness
unset req.http.X-Filtered-Cookie;
log "Filtered Cookie header: " req.http.Cookie;