You can set the domain on the persistence cookie that LTM sets from the cookie insert persistence profile. You don't need to set or modify the cookie value.
when HTTP_RESPONSE {
log local0. "[IP::client_addr]:[TCP::client_port]: Pre Set-Cookies: [HTTP::header values Set-Cookie]"
Check if the persistence cookie exists in the response
if {[HTTP::cookie exists "My_cookie"]} {
set the domain attribute on the persistence cookie
HTTP::cookie domain "My_cookie" ".mydomain.com"
log local0. "[IP::client_addr]:[TCP::client_port]: Modified domain on My_cookie"
}
log local0. "[IP::client_addr]:[TCP::client_port]: Post Set-Cookies: [HTTP::header values Set-Cookie]"
}
If you want to use the same iRule on multiple virtual servers with different pools and corresponding persistence default cookie names, you could add logic to the iRule to look for a cookie name based on BIGipServer[LB::server name].
Aaron