Looking for Feedback/Efficiency on Cookie Removal
Background: We have a homegrown portal that users log in to and then launch applications from. This portal injects a ridiculous number of cookies into the client. One or more of these cookies prevent an application from working correctly. My iRule that I quickly made to 'fix' the issue is below. Since I cannot modify the response to expire the cookies I don't want since that will break other applications if they attempt to launch them, I have to scrub any of the cookies I don't want to get to this application on every incoming request.
Question(s):
1) Aside from fixing the portal (I want to replace it with APM...we'll see) is there another avenue I should be looking at to fix this besides an iRule?
2) Can my iRule be made more efficient through using switch or data groups? I couldn't figure out how to do that since I don't know of a way to do 'not equal' or not 'starts_with' within switch or how to get the data group syntax to work. There are more cookies I have to allow than included here. I shortened it.
when HTTP_REQUEST {
set cookies [HTTP::cookie names]
log local0. "Inbound cookies are $cookies"
foreach cookie $cookies {
if { !($cookie starts_with "f5" or $cookie starts_with "" or $cookie starts_with "") }{
HTTP::cookie remove $cookie
log local0. "Removing cookie $cookie"
}
}
}