Forum Discussion
MaheshV_65076
Nimbostratus
May 22, 2008jsessionid persistence
We recently started to use F5 8800 & 6800 in our environment. But we aren’t able to make sticky sessions work.
I browsed through the dev central and found couple of solutions (
http://d...
Deb_Allen_18
Jun 06, 2008Historic F5 Account
As hoolio mentions, you can delete entries using the “session delete” or “persist delete” commands, but entries will expire out of the table with the idle timeout expiry. In your code, the timeout is set to 1800 seconds, or 30 minutes.
That should happen by default unless your rule specifies otherwise. if the timeout is set to match the cookie timeout, or (the intended application idle timeout if using session cookies).
There is actually a slightly more efficient example in the codeshare here (uses a bit simpler approach for the response): Click here
(Note that for this version, timeouts are controlled by the persistence profile via which it is applied to the virtual server.)
I’d change your request logic also so the logic after the redirect only runs if the redirect doesn’t.
You also mentioned in email that this solution isn't working across http & https virtuals, and that requires a specific session command parameter "any virtual"
I’d recommend using something more along these lines (although you might have to adjust what part of jsessionid value you are using):
when HTTP_REQUEST {
if { [active_members MyPool] == 0 } {
HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/myUri.html"
} else {
if { [HTTP::header exists "X-Forwarded-Host"] } {
HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
}
if { [HTTP::cookie exists "JSessionID"] } {
log "used Cookie, value is [HTTP::cookie "JSessionID"]"
persist uie {[HTTP::cookie "JSessionID"] any virtual}
} else {
set jsess [findstr [HTTP::uri] "JSessionID" 11 ";"]
if { $jsess != "" } {
persist uie {$jsess any virtual}
}
}
}
}
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSessionID"] } {
persist add uie {[HTTP::cookie "JSessionID"] any virtual}
}
}
HTH
/deb
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