Clearing cookies for site with iRule
We believe we have some users with bad cookies on their system. Its not practical to ask all users to delete their cookies so we want to force them to expire with an f5 iRule.
There is an HTTP::cookie remove query but my impression is that removes the cookie either from the request or the response. It doesn't clear the cookie from the users system. Instead it seems like we need to set the expiry on all cookies to a date in the past.
I am trying to do that with the following iRule with no luck:
when HTTP_RESPONSE {
# check to see if the cookie cookie_version2 exists if it doesn't clear the cookies
# this ensures cookies only get cleared once.
if {not [HTTP::cookie exists "cookie_version2"]} {
log local0. "[IP::client_addr] cookie_version2 does not exist"
set Cookies [HTTP::cookie names]
foreach Cookie $Cookies {
log local0. "$Cookie expired"
HTTP::cookie expires $Cookie 0 absolute
}
log local0. "ALL COOKIES EXPIRED (x_x)"
#log local0. "Add cookie cookie_version=1 to track if the cookies have been cleared before or not"
HTTP::cookie insert name "cookie_version2" value "1" path "/"
HTTP::cookie attribute cookie_version2 value "expires" "Thu, 09-April-2022 00:00:00 GMT"
}
}
Can anyone help me figure out why this isn't working as expected. My impression is that the client sends all cookies with the request does the server not send all cookies back with the response? Is that why its not working?
I also see references to HTTP::expires only applying to version 0 cookies only in the documentation. But how do I know if my cookies aer version 0,1,2. Do I need to do this differently for other cookie versions?
Thanks,
Brad