<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
.MsoChpDefault
        {font-family:"Calibri","sans-serif"}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}
ol
        {margin-bottom:0in}
ul
        {margin-bottom:0in}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello</p>
<p class="MsoNormal">   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:</p>
<p class="MsoNormal">        </p>
<p class="MsoNormal">              if(resp.status != 503) {                     </p>
<p class="MsoNormal">                                set resp.http.Set-Cookie = "my_error_cookie =false; expires: Session; path=/";</p>
<p class="MsoNormal">                }</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">The problem is that the cookies received from apache are rewritten, if I use this I never receive the
<span style="color:black; background:white">PHPSESSID  cookie. For debug proposes I added this code :</span></p>
<p class="MsoNormal"><span style="color:black; background:white"> </span></p>
<p class="MsoNormal">              set resp.http.X-Cookie-Debug = "Response cookie: " + resp.http.Set-Cookie;</p>
<p class="MsoNormal"></p>
<p class="MsoNormal">                                if(resp.status != 503) {                  
</p>
<p class="MsoNormal">                                set resp.http.Set-Cookie = " my_error_cookie=false; expires: Session; path=/";</p>
<p class="MsoNormal">                }</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">                set resp.http.X-Cookie-Debug2 = "Response cookie2: " + resp.http.Set-Cookie;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">These are the headers that browser receives :</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-right:0in; margin-bottom:.75pt; margin-left:0in; text-indent:-.25in; background:white; vertical-align:top">
<b><span style="color:#545454"><span style="">1.<span style="font:7.0pt "Times New Roman"">      
</span></span></span></b><b><span style="color:#545454">X-Cookie-Debug:</span></b></p>
<p class="MsoNormal" style="margin-bottom:.75pt; background:white; word-break:break-all">
<span style="color:black">Response cookie: PHPSESSID=egf2tthsj0fm2bmt1oircumgk6; path=/</span></p>
<p class="MsoNormal" style="margin-right:0in; margin-bottom:.75pt; margin-left:0in; text-indent:-.25in; background:white; vertical-align:top">
<b><span style="color:#545454"><span style="">2.<span style="font:7.0pt "Times New Roman"">      
</span></span></span></b><b><span style="color:#545454">X-Cookie-Debug2:</span></b></p>
<p class="MsoNormal" style="margin-bottom:.75pt; background:white; word-break:break-all">
<span style="color:black">Response cookie2: </span>my_error_cookie=false<span style="color:black">; expires: Session; path=/</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">And there is only one  Set-Cookie header :</p>
<p class="MsoNormal" style="background:white; vertical-align:top"><b><span style="color:#545454">Set-Cookie:</span></b></p>
<p class="MsoNormal" style="background:white; word-break:break-all">my_error_cookie=false<span style="color:black">; expires: Session; path=/</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Can you tell me how can I set a new cookie without losing the cookies that apache sends ?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thank you very much</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
</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>