Forum Discussion

Mia_27938's avatar
Mia_27938
Icon for Nimbostratus rankNimbostratus
Jul 29, 2014

The iRule delete cookies regardless of the cookies's name.

If HTTP request header has image value, I would like to delete the cookies in the HTTP request header regardless of the cookie's name.

 

So I made the following sample iRule;

 

when HTTP_REQUEST { if { [HTTP::header "Accept"] starts_with "image" } { HTTP::cookie remove "cookie name" } }

 

However, if the cookies named is random, how to modify above iRule?

 

Please help

 

Thank you

 

2 Replies

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    Will the header remove help?

    when HTTP_REQUEST {   
       HTTP::header remove Cookie
    }
    
  • If an HTTP request has any cookies, they'll all be in a single Cookie header.

     

    GET / HTTP/1.1
    Host: www.domain.com
    Cookie: foo=bar; test=blah; this=that;

    If you want to simply remove ALL of the cookies, then you simply remove the Cookie header as Kunjan showed. If you want to remove a specific cookie, then you need to parse the cookie header and strip out the specific key/value that you're looking for. It's also worth nothing that the above example will only remove the cookie header from the ingress flow. It'll have no effect on the client that still has and will continue to use the cookie unless either the application rewrites/deletes it, or you implement some iRule code to do the same.