iRule to take cookie from HTTP Response into HTTP Request via table
Sanitized version of an iRule. It’s main function is to take a cookie from a HTTP Response; put the value into a table and then insert into a HTTP request.
The switch statement section has been stripped right back. So please re-construct to your own needs.
The iRule contains some failsafe testing table look-ups and logging.
when HTTP_REQUEST {
#
set requestjcookie "jcookie"
set dailycookie [table lookup -subtable "change-me-cookie" $requestjcookie]
#
#log local0. "CHANGE-ME: HTTP Request Cookie $dailycookie"
#
switch -glob [HTTP::path] {
Note: Section stripped back. Please re-create as per the need
HTTP::cookie remove "JSESSIONID"
HTTP::cookie insert name "JSESSIONID" value $dailycookie
}
}
when HTTP_RESPONSE {
if { [HTTP::header exists "Set-cookie" ] } {
set cookies [HTTP::cookie names]
foreach cookie $cookies {
set cookie_value [HTTP::cookie $cookie]
# log local0. "CHANGE-ME: $cookie_value"
set responsejcookie "jcookie"
table set -subtable "change-me-cookie" $responsejcookie $cookie_value indef
table replace -subtable "change-me-cookie" $responsejcookie $cookie_value indef
set viewtb [table lookup -subtable "change-me-cookie" $responsejcookie]
# log local0. "CHANGE-ME: Listing $viewtb"
}
}
}