Forum Discussion

Angel_Martinez_'s avatar
Angel_Martinez_
Icon for Nimbostratus rankNimbostratus
Sep 18, 2009

iRules, persistences, persistence profiles.

Hi

 

I've some doubts... I'll try to explain myself so apologizes for my English...

 

 

- Could anyone give me the differences between using: "session add uie $MyCookie 100" vs "persist uie $MyCookie 100", please ¿?

 

 

- I would like to use persistence with cookies from an iRule, should I manage this iRule as a persistence profile or just like a normal iRule...

 

 

- Is a good practice using a profile persistence "cookie in mode insert" and using iRules as a resource (with this situation I don't have to put Set-Cookie at the first HTTP_RESPONSE event).

 

 

 

FYI: (is an example in lab environment... I should reduce the memory impact etc..).

 

 

 

when HTTP_REQUEST {

 

set SwSetCookie 0

 

if { [HTTP::cookie "MyCookie"] != ""} {

 

set Cookie [HTTP::cookie "MyCookie"]

 

persist uie $Cookie 100

 

log local0.alert "Valor de la Cookie: $Cookie"

 

} else {

 

log local0.alert "No tengo Cookie activo el SW de Set-Cookie"

 

set SwSetCookie 1

 

}

 

pool MyPool

 

}

 

 

 

when HTTP_RESPONSE {

 

if { [HTTP::header Set-Cookie] starts_with "MyCookie" } {

 

set NuevaCookie [getfield [getfield [HTTP::header Set-Cookie] "=" 2] ";" 1]

 

log local0.alert "Add Persistencia Cookie: $NuevaCookie contra $MyServer"

 

persist add uie $NuevaCookie 100

 

}

 

}

 

 

 

when SERVER_CONNECTED {

 

if { $SwSetCookie == "1" } {

 

set MyServer [IP::server_addr]

 

log local0.alert "Primera conexion contra el servidor: [IP::server_addr]"

 

}

 

}

2 Replies

  • The easiest and most efficient way to ensure clients are persisted to the same pool member over the duration of a session is to use cookie insert persistence using the profile. This works well, is simple to configure and is more efficient than trying to mimic the functionality in an iRule.

     

     

    The session commands add/retrieve/modify session table entries. On their own, no changes are made to pool member selection. It's just a way to store name - value pairs in the LTM memory. If you wanted to use the session table for persistence, you would need to explicitly select the pool member based on the session table entry or use the value as input for a persist command.

     

     

    The persist commands allow you to add/retrieve/modify/use persistence table entries.

     

     

    Aaron
  • Hi Aaron

     

     

    Thanks for your answer.

     

     

    So I let to the BigIP manages the cookie insert through the Persistence Profile and afterward I'll look for the cookie in the iRule for the Pool selection and different actions.

     

     

    Bye.