Hashing on a particular cookie value

Paul A. Procacci pprocacci at datapipe.com
Thu Nov 8 11:07:56 CET 2012

> Thanks a lot Paul. Before I read this , I tried the following :
> hash_data(regsub(req.http.Cookie,"^.*?mycookie=([^;]*);*.*$" , "\1"));

Your regex differs than mine.  One negligible difference and one that
I'll focus on.  The negligible difference being the anchors "^" and "$".
They aren't necessary.

For reference, my regex was:
regsub(req.http.cookie, ".*mycookie=([^;]+);.*",


The difference is that I'm looking for a value in my regex, and you
don't care if there is a value in yours.  '+' vs '*'.

Your regex matches:

My regex _doesn't_ match:

If you want to hash on an empty cookie, then your regex is what you
want.  Otherwise, perhaps mine is what you want.

You know your application best, and how you want to store your
data is entirely dependant upon you.  ;P


> I guess this should also do the trick ?
> Regards
> Soumendu


This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.

More information about the varnish-misc mailing list