Forum Discussion

GaryZ_31658's avatar
GaryZ_31658
Historic F5 Account
Sep 13, 2007

Persist on BIG-IP Session Cookie first else use use Server Cookie to select Pool

I am hoping to use a server cookie to select a pool based on matching data in the cookie. I would like to then use a BIG-IP Session Cookie to persist normally. Is there a better way to handle this? Will BIG-IP know what pool to use based on the session cookie? (The server cookie will contain site"x" along with other data and the TTL will be indefinite.)

 

 

The goal is to allow us to define which users get the updated site by defining them in the group new_site_users and still maintain persistence once they get there. We also want to trap users that are transacting with either the new site or the old site so they don't switch if we update the new_site_user list while they are transacting.

 

 

when HTTP_REQUEST {

 

if {[HTTP::cookie exists "bigip_cookie"]{

 

persist my_defined_cookie-persist_profile

 

}

 

elseif {[HTTP::cookie exists "server_cookie"]}{

 

if { [matchclass [HTTP::cookie value "server_cookie"] contains $::new_site_users] } {

 

pool new_site_pool

 

}

 

else {

 

pool original_site_pool

 

}

 

}

 

}

 

 

Data Group new_site_users

 

siteA

 

siteB

 

siteC
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    I'd apply a cookie insert persistence profile to the virtual server, using the default cookie name [BIGipServer].

    Then in your iRule, first look for an LTM persistence cookie and pick the pool based on the cookie name.

    If no persistence cookie exists, then inspect the server-set cookie. If it contains a new_site_users class member, select the new_site_pool.

    If neither condition is true, select the original_site_pool.

    Class:
    class new_site_users {
      siteA
      siteB
      siteC
    }
    Rule:
    when HTTP_REQUEST {
       first look for LTM persistence cookie & extract pool name
      set myPool [findstr [HTTP::cookie names] "BIGipServer" 11 " "]
      if {$myPool != "" }{
        pool $myPool
      } elseif {[HTTP::cookie exists "server_set_cookie"] && \
       [matchclass [HTTP::cookie "server_cookie"] contains $::new_site_users]}{
         pool new_site_pool
      } else {
         pool original_site_pool
      }
    }