Forum Discussion
newbie persistence question cookie and/or message body
rule http_persist_rl2 {
when HTTP_REQUEST {
check for SessionId Cookie
set session ""
if { [HTTP::cookie exists "SessionId"] } {
if { [HTTP::cookie "SessionId"] != ""} {
set session [HTTP::cookie "SessionId"]
}
}
check for Set-Cookie header with SessionId
else if {[HTTP::header count "Set-cookie" ] > 0 } {
set all_set_cookies [HTTP::header "Set-cookie" ]
foreach one_set_cookie $all_set_cookies {
if { $one_set_cookie contains "SessionId" } {
set session [ findstr($one_set_cookie,"SessionId=",10,';') ]
}
}
}
check for SessionId in the body if the method is POST
else if {http_method == "POST" and findstr(http_content,"SessionId=",10,'&') != ""} {
set session [findstr(http_content,"SessionId=",10,'&')]
}
if { $session != "" } {
LB:detach
persist uie [ $session ]
}
}
when HTTP_RESPONSE {
set session ""
check for SessionId Cookie
if { [HTTP::cookie exists "SessionId"] } {
if { [HTTP::cookie "SessionId"] != "" } {
set session [HTTP::cookie "SessionId"]
}
}
check for Set-Cookie header with SessionId
else if {[HTTP::header count "Set-cookie" ] > 0 } {
set all_set_cookies [HTTP::header "Set-cookie" ]
foreach one_set_cookie $all_set_cookies {
if { $one_set_cookie contains "SessionId" } {
set session [ findstr($one_set_cookie,"SessionId=",10,';') ]
}
}
}
check for SessionId in the body
XML response id
else if { findstr(http_content,"SessionId>",9,'<') != "" } {
set session [findstr(http_content,"SessionId>",9,'<')]
}
if { $session != "" } {
persist add uie [ $session ]
}
}
}
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com