Forum Discussion
Sashi_81625
Nimbostratus
Mar 26, 2012persisting the jsessionid cookie within F5 session table
Use Case:
we have in-house search servers that will crawl the customer-facing application. the limitations with our search software is that it doesnt persist the connections to app server a...
Sashi_81625
Nimbostratus
Mar 26, 2012
when HTTP_REQUEST {
set sid ""
set hostid [getfield [HTTP::host] "." 1]
if { [HTTP::uri] starts_with "/static" } {
HTTP::respond 200 OK
} else {
set key [URI::query [HTTP::uri] "f5key"]
if {$key != ""} {
if f5key is present in query parameters
persist the request first
persist uie "$hostid$key"
set path [URI::decode [URI::path[HTTP::uri]]]
retrieve the jsessionid cookie value from F5 session table
set sid [table lookup "$key$hostid"]
insert the cookie value so that application can reuse it
HTTP::header insert Cookie "JSESSIONID=$sid"
update the URI without query parameters
HTTP::uri $path
}
}
}
when SERVER_CONNECTED {
I chose 1200 as timeout because application
has 20mins as session idle timeout
set prid [table add "pkey$hostid" 5999 1200]
if { $prid < 6300 } {
set prid [table incr "pkey$hostid"]
create persistence record based on hostname and key
persist add uie "$hostid$prid" 1200
}
}
when HTTP_RESPONSE {
table add "skey$hostid" 5999 1200
if {$key != ""} {
set cid $key
} else {
set cid [table incr "skey$hostid"]
if { $cid > 6300 } {
set cid [table set "skey$hostid" 6000 1200]
}
}
if JSESSIONID shows up in set-cookie header
store it in F5 session table
if { [HTTP::cookie exists "JSESSIONID"] } {
set sid [HTTP::cookie value JSESSIONID]
table set "$cid$hostid" $sid 1200
}
if { [HTTP::status] starts_with "3" } {
set location [URI::decode [HTTP::header Location]]
pass the key as query parameter
set query "?f5key=$cid"
set newLocation "$location$query"
HTTP::header replace Location $newLocation
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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