<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
</head>
<body>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt"><span lang="en-US">
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">Hello</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">   I am using Varnish 3 in in front of apache with php.  I need to set a cookie in the browser every time the user doesn’t receive a 503 response I use the following
 code:</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">       
</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">              if(resp.status != 503) {                    
</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                                set resp.http.Set-Cookie = "my_error_cookie =false; expires: Session; path=/";</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                }</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">The problem is that the cookies received from apache are rewritten, if I use this I never receive the
<font color="black"><span style="background-color:white">PHPSESSID  cookie. For debug proposes I added this code :</span></font></span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"><font color="black"><span style="background-color:white"> </span></font></span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">              set resp.http.X-Cookie-Debug = "Response cookie: " + resp.http.Set-Cookie;</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                                if(resp.status != 503) {                  
</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                                set resp.http.Set-Cookie = " my_error_cookie=false; expires: Session; path=/";</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                }</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">                set resp.http.X-Cookie-Debug2 = "Response cookie2: " + resp.http.Set-Cookie;</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">These are the headers that browser receives :</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="text-indent:-18pt; background-color:white; margin:0 0 0.75pt 0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white"><font color="#545454"><b>1.</b></font><font color="#545454"><span style="font-size:"><b>      
</b></span></font><font color="#545454"><b>X-Cookie-Debug:</b></font></span></font></div>
<div style="background-color:white; margin:0 0 0.75pt 0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white"><font color="black">Response cookie: PHPSESSID=egf2tthsj0fm2bmt1oircumgk6; path=/</font></span></font></div>
<div style="text-indent:-18pt; background-color:white; margin:0 0 0.75pt 0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white"><font color="#545454"><b>2.</b></font><font color="#545454"><span style="font-size:"><b>      
</b></span></font><font color="#545454"><b>X-Cookie-Debug2:</b></font></span></font></div>
<div style="background-color:white; margin:0 0 0.75pt 0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white"><font color="black">Response cookie2:
</font>my_error_cookie=false<font color="black">; expires: Session; path=/</font></span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">And there is only one  Set-Cookie header :</span></font></div>
<div style="background-color:white; margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white"><font color="#545454"><b>Set-Cookie:</b></font></span></font></div>
<div style="background-color:white; margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt; background-color:white">my_error_cookie=false<font color="black">; expires: Session; path=/</font></span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">Can you tell me how can I set a new cookie without losing the cookies that apache sends ?</span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt"> </span></font></div>
<div style="margin:0"><font face="Calibri,sans-serif" size="2"><span style="font-size:11pt">Thank you very much</span></font></div>
</span></div>
<br>
<br>
<b>Cornel Vaideanu</b><br>
<b>PHP Developer</b><br>
<br>
M: <br>
<br>
<img src="http://greppysystems.com/ftp/logo.png"> <br>
17-19A, Ploiesti Street, <br>
Cluj-Napoca, Romania<br>
<a href="http://greppysystems.com">www.greppysystems.com</a><br>
</body>
</html>