Skip to content

Instantly share code, notes, and snippets.

@cdgraff
Last active November 8, 2020 13:11
Show Gist options
  • Save cdgraff/6b685b0baba2cb6369c90b845f00cf42 to your computer and use it in GitHub Desktop.
Save cdgraff/6b685b0baba2cb6369c90b845f00cf42 to your computer and use it in GitHub Desktop.
Varnish VCL code examples for HLS stats
sub vcl_recv {
# Only userid are left in req.http.cookie at this point.
cookie.parse(req.http.cookie);
cookie.filter_except("userid");
if (cookie.isset("userid")) {
std.log("userid value is: " + cookie.get("userid"));
} else {
cookie.set("userid", regsub(std.random(0, 320000000), "\..*", ""));
std.log("userid value is: " + cookie.get("userid"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment