Forum Discussion

iiifa's avatar
iiifa
Icon for Nimbostratus rankNimbostratus
Jan 12, 2022

irule to remove all cookies

Hello,

we are testing an irule to remove all cookie from the client browser after an idle time, the cookie for TCP isn't what we are looking for rather than the actual cookie sent to the server.

any suggestion on how to achieve this, if I inserted a cookie manually I want the irule to delete it after I refresh the page.

we are testing this on BIG-IP LTM

?irule example :

when HTTP_REQUEST {


        


}


when HTTP_RESPONSE {
    set cookieNames [HTTP::cookie names] #array of cookies 
        foreach aCookie $cookieNames { #adding the cookies to the array in a varaible aCookie
         HTTP::cookie remove $aCookie #removing the virable 
        }


}

  • Something like this:

    when HTTP_REQUEST {
        set request_cookies [HTTP::cookie names]
    }
     
    when HTTP_RESPONSE {
        foreach a_cookie $request_cookies {
            log local0. "Remove cookie: $a_cookie"
            HTTP::header insert Set-Cookie "$a_cookie=deleted;expires=Thu, 01-Jan-1970 00:00:10 GMT;path=/"
        }
    }