Forum Discussion

Blue_whale's avatar
Blue_whale
Icon for Cirrocumulus rankCirrocumulus
May 30, 2019

Irule - How this Secure Cookie Irule works ?

Can some one explain how this SECURE_COOKIE Irule works .

 

 

ltm rule SECURE_COOKIE {

  when HTTP_RESPONSE_RELEASE { 

set unsafe_cookie_headers [HTTP::header values "Set-Cookie"] 

HTTP::header remove "Set-Cookie" 

foreach set_cookie_header $unsafe_cookie_headers { 

HTTP::header insert "Set-Cookie" "${set_cookie_header}; Secure" 

}

}

4 Replies

    • Dario_Garrido's avatar
      Dario_Garrido
      Icon for MVP rankMVP
      when HTTP_RESPONSE_RELEASE {
      	# Get all values of Set-Cookie headers
      	set unsafe_cookie_headers [HTTP::header values "Set-Cookie"]
      	# Remove the current unsafe Set-Cookie header
      	HTTP::header remove "Set-Cookie"
      	foreach set_cookie_header $unsafe_cookie_headers {
      		# Insert a new Set-Cookie header with '<value>; Secure' for each one (to securize)
      		HTTP::header insert "Set-Cookie" "${set_cookie_header}; Secure"
      	}
      }