@@ -427,28 +427,25 @@ sub vcl_deliver {
427427 set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session +
428428 "; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/" ;
429429 if (req.http.Host ) {
430+ if (req.http.Host ~ "{{normalize_cookie_regex}}" && "{{normalize_cookie_regex}}" ~ ".." ) {
431+ set resp.http.X-Varnish-CookieDomain = "{{normalize_cookie_target}}" ;
432+ } else {
433+ set resp.http.X-Varnish-CookieDomain = regsub (req.http.Host , ":\d +$" , "" );
434+ {{set_cookie_domain}}
435+ }
430436 if (req.http.User-Agent ~ "^(?:{{crawler_user_agent_regex}})$" ) {
431437 # it's a crawler, no need to share cookies
432438 set resp.http.Set-Cookie = resp.http.Set-Cookie +
433439 "; domain=" + regsub (req.http.Host , ":\d +$" , "" );
434440 } else {
435441 # it's a real user, allow sharing of cookies between stores
436- if (req.http.Host ~ "{{normalize_cookie_regex}}" && "{{normalize_cookie_regex}}" ~ ".." ) {
437- set resp.http.Set-Cookie = resp.http.Set-Cookie +
438- "; domain={{normalize_cookie_target}}" ;
439- } else {
440- set resp.http.X-Varnish-CookieDomain = regsub (req.http.Host , ":\d +$" , "" );
441- {{set_cookie_domain}}
442- set resp.http.Set-Cookie = resp.http.Set-Cookie +
443- "; domain=" + resp.http.X-Varnish-CookieDomain ;
444- }
442+ set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + resp.http.X-Varnish-CookieDomain ;
445443 }
446444 }
447445 set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly" ;
448- if ({{reuse_new_visitor_esi_blocks}}) {
449- # @TODO Apply CookieDomain fixes
446+ if ({{reuse_new_visitor_esi_blocks}} && resp.http.X-Varnish-CookieDomain ) {
450447 header.append( resp.http.Set-Cookie , "turpentine_new=1; expires=" + resp.http.X-Varnish-Cookie-Expires +
451- "; path=/; domain=" + req .http.Host + "; httponly" );
448+ "; path=/; domain=" + resp .http.X-Varnish-CookieDomain + "; httponly" );
452449 }
453450 unset resp.http.X-Varnish-Cookie-Expires ;
454451 }
0 commit comments