I haven&#39;t tested this myself, but I believe it should do what you want.<br><br>if ($http_cookie !~ &#39;my_cookie=some_value&#39;) {<br>&nbsp;&nbsp;&nbsp; add_header&nbsp; Cookie&nbsp; &#39;my_cookie=some_value&#39;;<br>&nbsp;&nbsp;&nbsp; rewrite&nbsp; (.*)&nbsp;  $1&nbsp; last;<br>
&nbsp;&nbsp;&nbsp; break;<br>}<br># statements hereafter will only be reached if the cookie is properly set<br><br>I&#39;m not sure the &#39;break&#39; is necessary since the previous statement ends with &#39;last&#39;, but I see it in examples quite a bit.<br>
<br>Be mindful that this will cause an infinite loop (and an eventual client-side error message) for browsers with cookie support turned off.&nbsp; It might be better to redirect users to something like /cookie_added, then when a request comes in for /cookie_added, rewrite the request internally to remove /cookie_added from the URI and process as normal.&nbsp; You could even check the URI, and if it is for /cookie_added but the cookie is not set, you could show a friendly warning message instructing the user that cookies are required for your site.<br>
<br>Hope that helps.<br><br>Nick<br><br><br><br><div class="gmail_quote">On Thu, Jan 22, 2009 at 10:27 PM, Payam Chychi <span dir="ltr">&lt;<a href="mailto:pchychi@gmail.com">pchychi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey Guys,<br>
<br>
Im trying to see what the best way of doing this would be... any and<br>
all thoughts are greatly appreciated.<br>
<br>
a) client --&gt; proxy --&gt; [cookie set?] if yes, proxy connection to<br>
$origin. call it a day<br>
b) client --&gt; proxy --&gt; [cookie set?] if no, set cookie, redirect<br>
client to proxy and see if the cookie is set, if No, keep looping; if<br>
yes, proxy connection to $origin.<br>
<br>
I see that you can use the following ways to inject cookie into the header:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;add_header &nbsp; &nbsp;Cookie &nbsp;&quot;mysuperdoopercookiehere&quot;;<br>
or<br>
 &nbsp; &nbsp; &nbsp; &nbsp;userid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;on;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;userid_name &nbsp; &nbsp; uid;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;userid_domain &nbsp; <a href="http://domainname_here.com" target="_blank">domainname_here.com</a>;<br>
<br>
Using firefox cookie header add-on, ive been able to confirm that the<br>
cookie injection works just fine however, I haven&#39;t a clue on how to<br>
properly write the redirect so that if the cookie is not set, set it<br>
and have the client re-establish connection with the cookie added to<br>
the header &nbsp;and if the connection has a cookie set then pass it to the<br>
proxy.<br>
<br>
Any help with this would greatly be appreciated... ive been banging my<br>
head to my desk for the last 2 days.<br>
<br>
Thanks in advance,<br>
<font color="#888888">Payam<br>
<br>
</font></blockquote></div><br>