Forum Discussion

bedwards311_338's avatar
bedwards311_338
Icon for Nimbostratus rankNimbostratus
Jun 11, 2018

iRule - create cookie and insert value of client FQDN

I am trying to create an iRule that will create a cookie on the client and insert the client FQDN and client IP address into the cookie. So far, the iRUle will insert the client IP address but I can't find how to insert the client FQDN. Any help would be appreciated. Thanks

 

when HTTP_RESPONSE {

 

Check if the cookie exists in request

if { not ( [HTTP::cookie exists "LBSRC"] ) } {

 

Change cookie's value

HTTP::cookie insert name "LBSRC" value [IP::client_addr] } }

 

1 Reply

  • Hi,

    try this:

    when HTTP_REQUEST {
    
    set hostname [HTTP::host]
    set client_ip [IP::client_addr]
    set nocookie 1
    
    
    if { [HTTP::cookie exists LBSRC] } {        
    set nocookie 0
    }
    
    
    }
    when HTTP_RESPONSE {
    if {$nocookie} {
      HTTP::cookie insert name LBSRC value "$hostname $client_ip"
    }
    }
    

    Let me now if you need more details...

    Regards