Forum Discussion
Han_Chen_105362
Nimbostratus
Apr 15, 2006modifying a session persistent cookie based on selected server
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?
- Colin_Walker_12Historic F5 AccountWell, if you're trying to avoid inspecting the actual cookie, you could always build a data group that contains the IP address of the destination server, along with the name to append to the cookie. In this way you could stop inspecting the cookie, and just do a findclass on your data group to find the IP matching the current destination address, and then extract the name portion to be appended.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects