Forum Discussion
vlavergne_12825
Jul 28, 2005Historic F5 Account
Persist on the SET Cookie response from the server
Hi F5 Rulers !
I am currently having a customer with an iRule who want to persist on the SET COOKIE message contained in the server Response to the FIRST client REQUEST.
I would like to know if the HTTP::Cookie will intercept this Set Cookie from the Server ????
If it is failing, how can I work around it ?
Here is what my Rule look like so far :
rule SESSIONID_one {
when HTTP_RESPONSE {
if { [HTTP::cookie exists "SESSIONID"] } {
set serv_cookie [persist lookup uie [HTTP::cookie "SESSIONID"] ]
if { $serv_cookie != ""} {
log local.0 "Cookie SESSIONID $serv_cookie already exists and generated by [IP::server_add] for client [IP::client_addr]"
}
persist add uie [HTTP::cookie "PHPSESSID"]
}
when HTTP_REQUEST {
if { [HTTP::cookie exists "SESSIONID"] } {
set pl [persist lookup uie [HTTP::cookie "SESSIONID"] ]
if { $pl ne "" } {
pool HTTP member [lindex $pl 1] [lindex $pl 2]
} else {
pool HTTP
}
}
}
}
Thanks for your response
Vincent
- unRuleY_95363Historic F5 AccountYes, in HTTP_RESPONSE, HTTP::cookie parses the Set-Cookie headers.
- vlavergne_12825Historic F5 AccountYou are right but I hadn't any BIG-IP in front of me to verify !! That will be nice to have such an interface on devcentral to verify the rule syntax... However here is the final rule
when HTTP_REQUEST { if { [HTTP::cookie exists "PHPSESSID"] } { set pl [persist lookup uie [HTTP::cookie "PHPSESSID"] ] if { $pl ne "" } { pool front member [lindex $pl 1] [lindex $pl 2] } else { log local.0 "Session ID [HTTP::cookie "PHPSESSID"] expired on the server for client [IP::client_addr]" pool front } } } when LB_FAILED { pool front log local.0 "LB Failed for client [IP::client_addr]" LB::reselect } when HTTP_RESPONSE { if { [HTTP::cookie exists "PHPSESSID"] } { set pl2 [persist lookup uie [HTTP::cookie "PHPSESSID"] ] if { $pl2 ne ""} { log local.0 "Existing Cookie PHPSESSID $pl2 generated by [IP::server_addr] and within persistance table [lindex $pl2 1] [lindex $pl2 2] for client [IP::client_addr]" } persist add uie [HTTP::cookie "PHPSESSID"] } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects