Skip to content

Instantly share code, notes, and snippets.

@rezan
Created May 30, 2017 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezan/2b398534675f7d0e7258ef85a880a696 to your computer and use it in GitHub Desktop.
Save rezan/2b398534675f7d0e7258ef85a880a696 to your computer and use it in GitHub Desktop.
VCS session tracking
vcl 4.0;
import cookie;
import std;
sub vcl_deliver
{
cookie.parse(req.http.cookie);
set req.http.X-vcsid = cookie.get("_vcsid");
if (req.http.X-vcsid == "") {
set req.http.X-vcsid = std.random(1, 10000000) + "." + std.random(1, 10000000);
set resp.http.Set-Cookie = "_vcsid=" + req.http.X-vcsid + "; HttpOnly; Path=/";
}
std.log("vcs-key:SESSION/" + req.http.X-vcsid + "/" + req.http.Host + req.url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment