Forum Discussion
Chris_Miller
Altostratus
Apr 22, 2010iRule for Cookie Removal
I have 2 DCs fronted by a software GTM solution. When a user makes a request, GTM checks to see if they have a "DC" cookie. If they don't, it round robins the request. In the event that DC1 gets the request, the F5 there sets a cookie named "DC" with the value "1" and a server cookie for server-persistency. That way, GTM looks at the cookie and gets DC persistency.
If a DC goes bad, GTM will send the request to the other DC even though the cookie exists. So, the F5 at DC2 may see a cookie named "DC" with the value of "1". If that happens, I want the F5 at DC2 to remove the cookie.
Am I on the right track here?
when HTTP_REQUEST {
set strDC [HTTP::cookie "DC"]
if { $strDC equals "1"} {
HTTP::cookie remove "DC"
HTTP::cookie remove "server"
}
}
- hoolio
Cirrostratus
If you want the client to delete a cookie you'd need to tell it to in the response. Using HTTP::cookie remove in HTTP_REQUEST is going to remove the cookie from the request that is proxied to the pool--it wouldn't have any effect on the client.when HTTP_REQUEST { if {[HTTP::cookie "DC"] eq "1"}{ set remove_cookies 1 } else { set remove_cookies 0 } } when HTTP_RESPONSE { if {$remove_cookies}{ HTTP::cookie remove "DC" HTTP::cookie remove "server" } }
- The_Bhattman
Nimbostratus
Hi Cript2000,when HTTP_REQUEST { set the value for location in the cookie set StrDC [HTTP::cookie "DC"] } when HTTP_RESPONSE { checks to see if there is a 1 or a cookie header with no value if { ($StrDC== "1") or {$StrDC=="" } { HTTP::cookie remove "DC" HTTP::cookie remove "server" } }
- Chris_Miller
Altostratus
Thanks guys - totally blanked and forgot I'd have to send it in the response. :-P - Rami_307440
Nimbostratus
You can insert a new session and that will overwrite the current one.
when HTTP_REQUEST { set logOut 0 if {(([HTTP::uri] ends_with "logout")} { set logOut 1 } } when HTTP_RESPONSE { if { $logOut == 1 } { set session_key "whatever0928340923any" HTTP::cookie insert name "DC" value $session_key HTTP::cookie insert name "server" value $session_key }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects