iRule When HTTP Response Behavior

I’m trying to do a thing where if the F5 detects that the pool does not have active members, it will redirect the users to a specific URL but in addition it will also delete a session cookie.

I learnt from another question here on DevCentral that the

HTTP::cookie remove

needs to be used in the HTTP Response section for it to remove cookies from the user’s browser.

So the question is, would the

HTTP::respond

command triggered from the iRule also trigger the

when HTTP_RESPONSE

section of the same iRule?

when HTTP_REQUEST {
  ...
  if { [active_members http_pool] = 0 } {
    HTTP::respond 302 noserver location "https://www.mywebsite.com"
    set pool_status "nomember"
  }
}

when HTTP_RESPONSE {
  if { $pool_status eq "nomember" } {
    HTTP::cookie remove "sessionID"
  }
}

There is an example of how to do this at: https://devcentral.f5.com/wiki/iRules.HTTP__respond.ashx.

The remove command will remove the cookie from the response, not ask the client to remove it from it’s cache…

To remove a cookie from client cache, you must set an expiration time before current time… the best practice is to set it to 1970!

when HTTP_REQUEST {
  ...
  if { [active_members http_pool] = 0 } {
    HTTP::respond 302 noserver location "https://www.mywebsite.com" Set-Cookie "sessionID=path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT"
  }
}