Insert App Cookies In Http Redirect

Problem this snippet solves:

This rule intercepts the application response and sends an HTTP redirect to the client with any cookies the application set in its response.

Code :

when HTTP_RESPONSE {

   # Check if the response matches our criteria
   if {$some_condition == 1}{

      log local0. "[IP::client_addr]:[TCP::client_port]: Matched the response check."

      if { [HTTP::header exists Set-Cookie] }{
         HTTP::respond 302 Location "http://example.com" Set-Cookie [join [HTTP::header values Set-Cookie] "; "]
      } else {
         HTTP::respond 302 Location "http://example.com"
      }
   }
}
Published Mar 18, 2015
Version 1.0
No CommentsBe the first to comment