Forum Discussion
Multiple jsessionid cookies on VS
Hi Joren,
how about using an iRule that prefixes each outgoing jsession cookie with POOL_${CurrentlySelectedPoolName}_* and then removes the prefix in the incomming direction.
- Outgoing direction:
- Original Header : "Set-Cookie:" "jsession=abc; secure; path=/"
- Translated Header : "Set-Cookie:" "POOL_YOURPOOL1_jsession=abc; secure; path=/"
- Incomming direction:
- Original Header : "Cookie:" "POOL_YOURPOOL1_jsession=abc;POOL_YOURPOOL2_jsession=abc;POOL_YOURPOOL3_jsession=abc"
- Translated Header : "Cookie:" "jsession=abc;POOL_YOURPOOL2_jsession=abc;POOL_YOURPOOL3_jsession=abc"
The required iRule code to translate/untranslate the cookie names will look like this...
when HTTP_REQUEST {
if { [HTTP::header value "Cookie"] ne "" } then {
HTTP::header replace "Cookie" [string map [list "POOL_[URI::basename [LB::server pool]]_" ""] [HTTP::header value "Cookie"]]
}
}
when HTTP_RESPONSE {
if { [set cookie_values [HTTP::header values "Set-Cookie"]] ne "" } then {
HTTP::header remove "Set-Cookie"
foreach cookie $cookie_values {
if { [string tolower $cookie] starts_with "jsession" } then {
HTTP::header insert "Set-Cookie" "POOL_[URI::basename [LB::server pool]]_$cookie"
} else {
HTTP::header insert "Set-Cookie" $cookie
}
}
}
}
Note: You have to apply the provided iRule on the individual backend-VS objects, so that the currrently selected pool name can be resolved by [URI::basename [LB::server pool]]. But depending on your detailed requirement and the configuration of the frontside VS (e.g. HTTP-Profile enabled) you could rewrite the iRule to use a different text-string as differentiator based on whatever information is feasible for you...
Cheers, Kai
Recent Discussions
Related Content
* 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