East_Coast_1151
Oct 09, 2013Nimbostratus
How to delete cookies with random names?
Hello,
I have a Web app that uses random cookie names that appear at different Web pages. I want to flush these cookies at logoff time.
Currently I am using the following irule.
Is there a more optimal way to do this?
Thank you
when HTTP_REQUEST {
Capture cookie names
set cookies [HTTP::cookie names]
foreach cookie $cookies {
if {not ($cookie_list contains $cookie) } {
set cookie_list "$cookie $cookie_list"
}
}
Store the cookie list in a session variable
ACCESS::session data set session.custom.cookie_list $cookie_list
}
when HTTP_RESPONSE {
Check if the logoff processing flag is set
if { $logoff == 1 } {
Remove all captured cookies
set cookies [split [ACCESS::session data get session.custom.cookie_list] " "]
foreach cookie $cookies {
if { not ($cookie equals "") } {
HTTP::header insert Set-Cookie "$cookie=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"
}
}
}
}