Forum Discussion

Gilles_Marec_33's avatar
Gilles_Marec_33
Icon for Nimbostratus rankNimbostratus
Jul 22, 2005

Cookie Persistence

Hi,

 

 

I need to set cookie persistence for website with 8 nodes

 

 

Currently we are using Cookie Hash, but it seems to fail.

 

 

Here is our mechanism :

 

 

A customer connect to the website and he receive a PHPSESSID, he enter his login and password, then we need to persist him based on the value of its PHPSESSID. The PHPSESSID is unique for the eight nodes.

 

 

Sometimes, components like flash puts cookie in URI (ex : /flash.php?PHPSESSID=1f8210f5355c336c233ab08ee3ce1bc7)

 

 

Can I implement an iRule to persist my customers ?

 

 

We can't use source_addr because of aol and other bad isp, we can't use cookie insert because some heavy clients can't accept it.

 

 

Thanks

 

 

Gilles
  • david_wang_2073's avatar
    david_wang_2073
    Historic F5 Account
    perhaps you can make reference to this one:

     

     

    rule WeblogicJSessionPersist {

     

    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

     

    }

     

    }

     

    }

     

     

    by replacing JSESSIONID with PHPSESSID and change [findstr [HTTP::uri] "jsessionid" 11 ";"] to [findstr [HTTP::uri] "PHPSESSID" 10 ";"]
  • Thanks, so I will try this

     

     

    -------------------------------------------------------------

     

    rule PHPPersist {

     

     

    when CLIENT_ACCEPTED {

     

    set add_persist 1

     

    }

     

     

    when HTTP_RESPONSE {

     

     

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

     

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

     

    set add_persist 0

     

    }

     

     

    }

     

     

    when HTTP_REQUEST {

     

     

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

     

    persist uie [HTTP::cookie "PHPSESSID"]

     

    } else {

     

    set phpsess [findstr [HTTP::uri] "PHPSESSID" 11 ";"]

     

    if { $phpsess != "" } {

     

    persist uie $phpsess

     

    }

     

    }

     

     

    }

     

     

    }

     

    --------------------------------------------------------------------