<HTML>
<HEAD>
<TITLE>Re: Cookie value compare, integer</TITLE>
</HEAD>
<BODY>
<FONT SIZE="2"><FONT FACE="Arial"><SPAN STYLE='font-size:10pt'>I am currently on Varnish 2.1.5. Looks like that vmod_std module was added in 3.x version. I was hoping to avoid getting into writing C code for this. Any other ideas?<BR>
<BR>
</SPAN></FONT></FONT><BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Arial"><SPAN STYLE='font-size:10pt'>> <BR>
> I am getting the value of a cookie and then trying to compare it to another<BR>
> integer value but am getting a compile error. Can I compare integers stored<BR>
> in the req object? Should I be going about this a different way?<BR>
<BR>
Use the conversion method in vmod_std:<BR>
<FONT COLOR="#0000FF"><U><a href="https://www.varnish-cache.org/docs/trunk/reference/vmod_std.html#integer">https://www.varnish-cache.org/docs/trunk/reference/vmod_std.html#integer</a><BR>
</U></FONT><BR>
-- <BR>
Andreas<BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT FACE="Arial"><SPAN STYLE='font-size:11pt'><BR>
<BR>
On 11/16/11 6:06 AM, "Lane, Richard" <<a href="rlane@ahbelo.com">rlane@ahbelo.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Arial"><SPAN STYLE='font-size:11pt'>Is anyone comparing cookie values that are integers?<BR>
<BR>
I am getting the value of a cookie and then trying to compare it to another integer value but am getting a compile error. Can I compare integers stored in the req object? Should I be going about this a different way?<BR>
<BR>
For example:<BR>
<BR>
--sitename.vcl<BR>
<BR>
sitename_recv{<BR>
<BR>
set req.http.compareVal=10;<BR>
set req.http.cookieVal=5;<BR>
<BR>
call cookieValCompare;<BR>
<BR>
}<BR>
<BR>
sub cookieValCompare{<BR>
<BR>
if( req.http.cookieVal < req.http.compareVal)<BR>
{<BR>
#do something extra<BR>
}<BR>
}<BR>
<BR>
<BR>
If I try to compile via the console I get:<BR>
<BR>
Message from VCC-compiler:<BR>
Expected ')' got '<'<BR>
(program line 109), at<BR>
(/etc/varnish/sitename.vcl Line 11 Pos 28)<BR>
if( req.http.cookieVal < req.http.compareVal )<BR>
---------------------------------#-----------------------------<BR>
Running VCC-compiler failed, exit 1VCL compilation failed<BR>
Command failed with error code 106<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>