On Tue, 8 Apr 2008 11:22:47 +0200
<[EMAIL PROTECTED]> wrote:

> A question about cookies in VCL.
> 
> Is there a way of handling cookies in VCL?
> 
> Like: 
> if(req.http.Cookies[userid] == "1234")
> 
> or
> 
> set req.http.Cookies[language] = "sv"

Kind of. vcl_recv looks like this:
sub vcl_recv {
 if (req.request != "GET" && req.request != "HEAD") {
   pipe;
 }
 if (req.http.Expect) {
   pipe;
 }
 if (req.http.Authenticate || req.http.Cookie) {
   pass;
 }
 lookup;
}

I changed it to this:
sub vcl_recv {
 if (req.request != "GET" && req.request != "HEAD") {
   pipe;
 }
 if (req.http.Expect) {
   pipe;
 }
 if (req.http.Authenticate || req.http.Cookie ~ "PHPSESSID") {
   pass;
 }
 lookup;
}

The change ist, that if somewhere in the Cookie-Header we have a
"PHPSESSID"-String i pass it. The Problem ist, that in our application
we are using Cookies in JavaScript. So nearly every page will be
"passed" by varnish, couse the browser will send the cookies set by
javascript to the server. In the new vcl_recv it ignores all other
cookies.
The only problem is, if some cookie's value would be "PHPSESSID", than
the request will also be "passed".

Kind regards

Flo
_______________________________________________
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc

Reply via email to