On 2011-07-27, at 1819, [email protected] wrote:

> 
> 
> if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~ 
> "member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)"))  {
> Execute what's here....
> }
> 
> What I *think* this should do is only "Execute what's here" if:
> there is not a member_id cookie
> there is not a member_id cookie that equals 0 or -1
> 
> Am I incorrect?

Let's build this up bit by bit:

(req.http.Cookie ~ "member_id=" && req.http.Cookie !~ "member_id=(0|-1)")

There is a cookie with a name ending in 'member_id', and it doesn't with 0 or 
-1.  We call this the member_id condition.

> (!(member_id condition || req.http.Cookie ~ "(guestSkinChoice|language)"))


The next bit is:

req.http.Cookie ~ "(guestSkinChoice|language)"

'getSkinChoice' or 'language' exists in any cookie name or value.  We call this 
one the preferences condition.

> (!(member_id condition || preferences_condition))

So we end up with a NOT-ed OR, meaning neither.  Hence, your condition means:

There is not a cookie with a name ending in 'member_id', or there is one that 
starts with 0 or -1. In addition, neither 'getSkinChoice' nor 'language' exist 
in any cookie name or value.

If you get confused by boolean logic it's best to write the conditions out as 
nested if statements.

Matt



_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to