Greg_Ryan_33844
Jul 20, 2010Nimbostratus
iRule to set a cookie based on url
Hi, this is one of my first iRules and I am completely at a loss. What I am trying to do is set a cookie based on a 'contains' in the url. Once the cookie is set then I want to switch the pool based on the cookie value. I can get the second part to work, what I can't seem to do is to set a cookie based on an if statement. Has anyone done anything like this?
when HTTP_REQUEST {
if { [HTTP::uri] contains "newAdmin=1" } {
set newadmin_cookie "1"
pool 81_pool
}
elseif { [HTTP::uri] contains "newAdmin=0" } {
set newadmin_cookie "0"
pool server_pool
}
if { ([HTTP::cookie value "newadmin"] equals "1") } {
pool 81_pool
}
elseif { ([HTTP::cookie value "newadmin"] equals "0") } {
pool server_pool
}
}
when HTTP_RESPONSE {
HTTP::cookie insert name "newadmin" value $newadmin_cookie path "/"
}