Forum Discussion

Chandru_01's avatar
Chandru_01
Icon for Nimbostratus rankNimbostratus
Dec 09, 2018

Variable assignment in irule

Dear All,

 

I need to set an irule variable in the HTTP_RESPONSE based on a condition, and make a decision on the next HTTP_REQUEST based on the variable value and unset the variable.

 

The problem is that the variable value that was set on HTTP_RESPONSE does not get reflected in the next HTTP_REQUEST. What should I do to make the variable hold its value.

 

example:

 

when HTTP_REQUEST { if { [ info exists var] and $var eq 1 }{

 

do something

unset var } }

 

when HTTP_RESPONSE { if { [HTTP::status] contains 302 and [HTTP::header "Location" ] eq "/vdesk/hangup.php3" } { set var 1 } }

 

  • Hi Guy,

    use a custom session variable in your iRule like the following:

    when HTTP_REQUEST { 
    if { [ACCESS::session data get session.custom.var] eq "1" }{
        do something
        ACCESS::session data set session.custom.var ""
    }
    }
    when HTTP_RESPONSE { 
    if { [HTTP::status] contains 302 and [HTTP::header "Location" ] eq "/vdesk/hangup.php3" } 
    {   
        ACCESS::session data set session.custom.var "1"
    }
    }   
    
  • The problem with your code is the next request can be in a different tcp connection... so the variable is not shared between response and request...

     

    Http response can be with http 1.0 version which means the tcp connection close just after response...

     

  • Hi,

     

    You have the opportunity to use the functionnality (OTP Verify) in vpe that allow you to activate 5 attempts. Or create via an empty box your need (verify your otp with loop:5)

     

    First of you use F5 native solution? for OTP.

     

    Why you can't use OTP Verify that allow you 5 attempts...

     

    regards