Forum Discussion

David_Oertli_18's avatar
David_Oertli_18
Icon for Nimbostratus rankNimbostratus
Jun 20, 2017

iRule to rewrite specific cookies to be secure

I am looking for assistance with re-writing cookie's set by a back end real server to be secure. I have read the below articles and am unable to convert the logic provided in this article to only re-write two specific cookie names. Also below is my attempt to get this to work.

https://support.f5.com/csp/article/K11324

and

https://devcentral.f5.com/questions/rewriting-cookies

   when HTTP_RESPONSE {  
     set cookie_names [HTTP::cookie names]
     if { $cookie_names contains "cookie1" || "cookie2" } {    
       foreach cookie $cookie_names {  
       HTTP::cookie secure $cookie enable }
       log local0. "The cookie $cookie was found and attributes modified."
      }
     }

Not sure what the problem is logging doesn't show me what I am looking for.

1 Reply

  • Try something like this:

    when HTTP_RESPONSE {
       foreach cookie [HTTP::cookie names] {
          if { $cookie contains "cookie1" || $cookie contains "cookie2" } {
             HTTP::cookie secure $cookie enable
          }
       }
    }