Forum Discussion

marlon_Gino-gi1's avatar
marlon_Gino-gi1
Icon for Nimbostratus rankNimbostratus
Jan 13, 2007

irule based on JSESSIONID cookie

hello Guys,

 

 

Im quite new with Irules, would just like to know how the irules below works.As per my understading the rules below will apply persistence if the JSESSIONID cookie exist. i would like to know if the client connects without the JSESSIONID, what will happen to the connection based on the irule below.

 

 

 

thanks in advance

 

 

 

when CLIENT_ACCEPTED {

 

set add_persist 1

 

}

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {

 

persist add uie [HTTP::cookie "JSESSIONID"]

 

set add_persist 0

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "JSESSIONID"] } {

 

persist uie [HTTP::cookie "JSESSIONID"]

 

} else {

 

set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]

 

if { $jsess != "" } {

 

persist uie $jsess

 

}

 

}

 

}

 

 

 

 

 

1 Reply

  • The key there is the HTTP_REQUEST event code;

     

     

    
    when HTTP_REQUEST {
      if { [HTTP::cookie exists "JSESSIONID"] } {
        persist uie [HTTP::cookie "JSESSIONID"]
      } else {
        set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]
        if { $jsess != "" } {
          persist uie $jsess
        }
      }
    }

     

     

    If the client connects without any JSESSIONID set (either as a cookie or as a URI parameter) then the rule will fall through without setting any actions - and in that case the user will be loadbalanced as per normal, using whatever algorithm you have set in the LTM pool.

     

     

    Aaron