Forum Discussion

Parveez_70209's avatar
Parveez_70209
Icon for Nimbostratus rankNimbostratus
Jun 04, 2014

Irule to Include Session-Persistence into /retail Instance

Hi,

Into the below Irule, the session persistence is mapped only with /storeperform extension, but now the requirement is to add the same rules even to /retail extension, kindly guide how I will modify the existing Irule.

when HTTP_REQUEST {

persist requests that start with /storeperform
if { [string tolower [HTTP::uri]] starts_with "/storeperform" } {
     Check if there is a RpSemSessionID cookie in the request
    if { [HTTP::cookie "RpSemSessionID"] ne "" } {
         Persist off of the cookie value with a timeout of 1 hour (3600 seconds)
        persist uie [string tolower [HTTP::cookie "RpSemSessionID"]] 3600
    } else {
         Parse the jsessionid from the query string
        set jsess [findstr [string tolower [HTTP::query]] "rpsemsessionid=" 15 "&"]
         Use the jsessionid from the path for persisting with a timeout of 1 hour (3600 seconds)
        if { $jsess != "" } {
            persist uie $jsess 3600
        }
    }
} else {
    do not perist any other requests
    persist none
}

}

when HTTP_RESPONSE { Check if there is a RpSemSessionID cookie in the response if { [HTTP::cookie "RpSemSessionID"] ne "" } { Add persistence record using cookie value with a timeout of 1 hour (3600 seconds) persist add uie [string tolower [HTTP::cookie "RpSemSessionID"]] 3600 } }

========================================

Kindly guide as I am starting out the concepts slowly with Irule.

Thanks and Regards Parveez

4 Replies

  • Hi Team,

     

    Kindly suggest how to include /retail into the existing Irule, which will enable sticky persistence even for /retail instance too( currently only /storeperform is configured)

     

    Thanks and Regards Parveez

     

  • can we just add one more uri in the if expression?

      if { [string tolower [HTTP::uri]] starts_with "/storeperform" or [string tolower [HTTP::uri]] starts_with "/retail" } {
    
  • Hi Nitass,

     

    Got you, how about the below, will it work ?

     

    when HTTP_REQUEST { persist requests that start with /storeperform if { [string tolower [HTTP::uri]] starts_with "/storeperform" } { Check if there is a RpSemSessionID cookie in the request if { [HTTP::cookie "RpSemSessionID"] ne "" } { Persist off of the cookie value with a timeout of 1 hour (3600 seconds) persist uie [string tolower [HTTP::cookie "RpSemSessionID"]] 3600 } else { Parse the jsessionid from the query string set jsess [findstr [string tolower [HTTP::query]] "rpsemsessionid=" 15 "&"] Use the jsessionid from the path for persisting with a timeout of 1 hour (3600 seconds) if { $jsess != "" } { persist uie $jsess 3600 return } } } elseif { [string tolower [HTTP::uri]] starts_with "/retail" } { Check if there is a RpSemSessionID cookie in the request if { [HTTP::cookie "RpSemSessionID"] ne "" } { Persist off of the cookie value with a timeout of 1 hour (3600 seconds) persist uie [string tolower [HTTP::cookie "RpSemSessionID"]] 3600 } else { Parse the jsessionid from the query string set jsess [findstr [string tolower [HTTP::query]] "rpsemsessionid=" 15 "&"] Use the jsessionid from the path for persisting with a timeout of 1 hour (3600 seconds) if { $jsess != "" } { persist uie $jsess 3600 return } } } } when HTTP_RESPONSE { Check if there is a RpSemSessionID cookie in the response if { [HTTP::cookie "RpSemSessionID"] ne "" } { Add persistence record using cookie value with a timeout of 1 hour (3600 seconds) persist add uie [string tolower [HTTP::cookie "RpSemSessionID"]] 3600 } }

     

    Thanks and Regards Parveez

     

  • how about the below, will it work ?

     

    since if-body is identical, why don't you just add the new uri to an existing if-expression?