Forum Discussion

Chad_Roberts_21's avatar
Chad_Roberts_21
Icon for Nimbostratus rankNimbostratus
Aug 23, 2007

Memory-resident variable question

I need to write an iRule that will track what cookie values are assigned by the back end servers and to which user IDs and store them for a certain period of time. This is a multi-part problem, and I don't know where to begin.

 

 

1. A global variable is one thing, but how do you dynamically create and maintain a table?

 

 

2. How can I keep a counter on the age of a value in this table and remove it after, say, 60 minutes?

 

 

My thought is that I could have three sets of values in the table: one with cookie values, the second with corresponding user IDs (which I'll extract from the payload), and the third with a clock scan at the time I add the values. I'll just have to add some logic somewhere else to clean up or something.

 

 

Thoughts? Is there an easier way?

 

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    1. session command

    2. session command

    3. Click here

    when HTTP_REQUEST {
       Don't allow data to be chunked
      if { [HTTP::version] eq "1.1" } {
        if { [HTTP::header is_keepalive] } {
          HTTP::header replace "Connection" "Keep-Alive"
        }
         HTTP::version "1.0"
      }
    }
    when HTTP_RESPONSE {
      if {[HTTP::cookie exists myCookie]}{
         trigger collection for up to 1MB of data if cookie exists
        if {([HTTP::header exists "Content-Length"]) && ([HTTP::header "Content-Length"] <= 1000000)}{
          set content_length [HTTP::header "Content-Length"]
        } else {
            set content_length 1000000
        }
        if { $content_length > 0 } {
          HTTP::collect $content_length
        }
      }
    }
    when HTTP_RESPONSE_DATA {
       grab client ID to use as session table entry key
      set clientID [findstr [HTTP::payload] "clientID=" 9 &]
      if {$clientID != ""}{
         if key value found, add session table entry with 300 sec timeout
        session add uie $clientID [HTTP::cookie myCookie] 300
      }
    }

    HTH

    /deb