I set up a virtual server with a custom session cookie persistent. The cookie name is set manually. The challenge I have is that the cookie value has to be appended a string based on the server selected. So far, I am able to get it to work. But I have to inspect the content of the cookie to do what I want. And I don’t think that’s optimal. Instead, I am hoping to find a way to append the custom string without looking up the actual value of the cookie. Below’s the iRule I created, the cookie name was set to “xyz” in the code.
when HTTP_REQUEST {
if {[HTTP::cookie exists “xyz”]} {
if { [HTTP::cookie “xyz”] starts_with “1779434762” } {
set newcookie [HTTP::cookie “xyz”]internet1
} else {
set newcookie [HTTP::cookie “xyz”]internet2
}
HTTP::header replace “cookie” “xyz=$newcookie”
}
}
The number “1779434762” corresponds to the IP address of the node in the session persistent cookie. The IP address is 10.5.16.106, translated into Hex 0A.05.10.6A, reverse the order 6A10050A and you will get 1779434762.
Any suggestion?