<div dir="ltr">Hi,<div><br></div><div>Be careful the method in the link given by Michael doesn't work.</div><div>To set a cookie, you must use the vmod header.</div><div><br></div><div>And in the subroutines <b>vcl_deliver</b> you must add sotmehting like this (just change the name of the cookie and the value) </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">header.append(resp.http.Set-Cookie, "VarnishCache="+resp.http.X-Cache+"path:/");</blockquote><div><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div><div><font color="#3366ff"></font>Because using the set resp.http.Set-Cookie = overwrite all Cookie written by the backend.</div><div><br></div><div><br>I just implement this method in my website to get Analytics stats of my Varnish</div><div><b><font color="#3366ff"><br></font></b></div><div><b><font color="#3366ff"><br></font></b></div><div><b><font color="#3366ff">Nicolas Delmas</font></b></div><div><a href="mailto:colas.delmas@gmail.com" target="_blank">http://tutoandco.colas-delmas.fr/</a></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div>
<br><div class="gmail_quote">2017-03-08 23:13 GMT+01:00 Michael Loftis <span dir="ltr"><<a href="mailto:mloftis@wgops.com" target="_blank">mloftis@wgops.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You're setting it in the wrong place/way.  To set a cookie in the<br>
browser you must set it in the response sent to the browser inside of<br>
say vcl_deliver.  There's no variables so if you need to propogate<br>
data from e/g vcl_recv you can set an "internal" header on the<br>
req....see say <a href="https://www.fastly.com/blog/vcl-cookie-monster" rel="noreferrer" target="_blank">https://www.fastly.com/blog/<wbr>vcl-cookie-monster</a> for an<br>
example.<br>
<div><div class="gmail-h5"><br>
On Wed, Mar 8, 2017 at 1:38 PM, Mike Alberghini <<a href="mailto:MAlberghini@habitat.org">MAlberghini@habitat.org</a>> wrote:<br>
> We’re trying to get a varnish setup running that sets a regional cookie.<br>
> I’m having some troubles getting it to work, so any advice will be<br>
> appreciated.<br>
><br>
> We’re running Drupal 8 and Varnish 4.1.5 with the geoip2 vmod.  IP<br>
> Geolocation is working fine, and our X-GeoIP headers are being set<br>
> correctly.  What I would like to do is have varnish set a "country” cookie<br>
> when requests to our home page come in.  I’ve got it manipulating the<br>
> req.http.Cookie header, but it does not seem to be actually setting a cookie<br>
> in the browser.  Any suggestions?<br>
><br>
> --<br>
><br>
> Mike Alberghini<br>
><br>
> Software Developer, Habitat for Humanity International<br>
><br>
> 270 Peachtree Street NW, Suite 1300, Atlanta, GA 30303<br>
><br>
> office phone: <a href="tel:%28404%29%20420-6751" value="+14044206751">(404) 420-6751</a><br>
><br>
> <a href="mailto:malberghini@habitat.org">malberghini@habitat.org</a> · <a href="http://habitat.org" rel="noreferrer" target="_blank">habitat.org</a> | Habitat. We build.<br>
><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> varnish-misc mailing list<br>
> <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
<br>
"Genius might be described as a supreme capacity for getting its possessors<br>
into trouble of all kinds."<br>
-- Samuel Butler<br>
<br>
______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a></font></span></blockquote></div><br></div></div>