The ASPSESSIONID cookie
name is specific to the IIS server and is based on the process ID of the IIS instance. The name should be remain unchanged so long as the PID for IIS stays the same. The
value of the cookie is specific to the user session.
I think the first issue to address is why persistence is failing. Until you know that, I don't think there is much you can do with an iRule to fix the problem.
You can use a rule to track the request and response info. Here is a draft rule I've been working on to validate persistence for a customer. Hopefully this will shed some light on when the failure occurs for you.
when HTTP_REQUEST {
set persist_cookie_name "persist_cookie"
set request_info "client: [IP::client_addr] -> [HTTP::uri]; Request cookies:"
inspect cookies if any are sent in the request
if {[HTTP::header exists "Cookie"]}{
loop through the names of all the cookies in the request
foreach aCookie [HTTP::cookie names] {
it's the ASPSESSIONID cookie, save the full name of the cookie (ASPSESSIONIDABCDEFGH)
if { [string tolower $aCookie] starts_with "aspsessionid"}{
set aspsessionid_name_request $aCookie
set request_info "$request_info $aCookie=[HTTP::cookie value $aCookie];"
} elseif {[string tolower $aCookie] eq $persist_cookie_name}{
save the cookie value if it's the persistence cookie
set persist_cookie_value_request [HTTP::cookie value $aCookie]
set request_info "$request_info $aCookie=[HTTP::cookie value $aCookie];"
}
}
}
}
when LB_SELECTED {
save the pool name, IP and port for the selected node
set request_info "$request_info selected node info: [LB::server]"
}
when HTTP_RESPONSE {
set request_info "$request_info; Response cookies: "
loop through the names of all the cookies in the response
foreach aCookie [HTTP::cookie names] {
it's the ASPSESSIONID cookie, save the full name of the cookie (ASPSESSIONIDABCDEFGH)
if { [string tolower $aCookie] starts_with "aspsessionid"}{
set aspsessionid_name_response $aCookie
set request_info "$request_info $aCookie=[HTTP::cookie value $aCookie];"
} elseif {[string tolower $aCookie] eq $persist_cookie_name}{
save the cookie value if it's the persistence cookie
set persist_cookie_value_response [HTTP::cookie value $aCookie]
set request_info "$request_info $aCookie=[HTTP::cookie value $aCookie];"
}
}
If the request contained an ASPSESSIONID or persist cookie, then the response should not.
This is because the BIG-IP and IIS servers servers only set the cookies if the client doesn't present a cookie
or the cookie the client does present is invalid
if { ([info exists persist_cookie_value_request] and [info exists persist_cookie_value_response])
or ([info exists aspsessionid_name_request] and [info exists aspsessionid_name_response])}{
set request_info "$request_info; PERSIST FAILURE!"
}
log local0. "\$request_info: $request_info"
}
The output looks like this:
: $request_info: client: 192.168.99.33 -> /test.html; Request cookies: ASPSESSIONID192.168.101.46=value2; selected node info: test_http_pool 192.168.101.45 80; Response cookies: ASPSESSIONID192.168.101.45=value1; persist_cookie=761637056.20480.0000;; PERSIST FAILURE!
Note that I was faking the IIS servers with two "nodes" that respond with cookies named ASPSESSIONID[node IP address].
Aaron