Slide 105
Slide 105 text
sub vcl_deliver {
if (edgestash.is_edgestash() && req.url == "/") {
set resp.http.x-session-raw = memcached.get("sf2s" + cookieplus.get("PHPSESSID", ""));
set resp.http.x-session-base = regsuball(resp.http.x-session-raw,"_sf2_attributes\|a:[0-9]+:\{","");
set resp.http.x-session-base = regsuball(resp.http.x-session-base,";}_sf2_meta\|a:.+","");
set resp.http.x-name = regsuball(resp.http.x-session-base,"^([^;]+;)*s:4:\x22name\x22;s:[0-9]+:
\x22([^\x22]+)\x22.+$","\2");
set resp.http.x-shopping-cart-items = regsuball(resp.http.x-session-base,"^([^;]+;)*s:19:\x22shopping-cart-
items\x22;i:([0-9]+).*$","\2");
edgestash.add_json({"
{
"name": ""} + resp.http.x-name + {"",
"shopping-cart-items": ""} + resp.http.x-shopping-cart-items + {""
}
"});
edgestash.execute();
unset resp.http.x-session-raw;
unset resp.http.x-session-base;
unset resp.http.x-name;
unset resp.http.x-shopping-cart-items;
if(resp.http.x-session-id ~ "[a-z0-9]+") {
cookieplus.setcookie_add("PHPSESSID", resp.http.x-session-id, 30d, req.http.Host, "/");
cookieplus.setcookie_write();
unset resp.http.x-session-id;
}
}
}