Forum Discussion
Steven_Ruby_872
Nimbostratus
Jan 17, 2006more fun with jsessionid persistence
so it seems that some people in development, have decided that we shouldnt make cookies a requirement in our webapp. That means if a clients browser doesnt allow cookies the COOKIE persistence wont work.
What is the best way to use both the COOKIE persistence and if there is no cookie then use UIE persistence based on the jsessionid in the uri?
Anyone have ideas?
sr
- Steven_Ruby_872
Nimbostratus
I get the general idea. My problem is it doesnt work. - JRahm
Admin
Is anyone successfully doing this? From a tcpdump, here is what I am interpreting: - Deb_Allen_18Historic F5 AccountFor setting the persistence entry on the response, the final rule in this post worked: (Click here) , although as noted, the server /can/ set more than one Set-Cookie header when setting multiple cookies, so you might need to do some additional coding to find it.
(of course adjusting the offset / length of findstr to match your cookie name & value lengths)if {[HTTP::cookie exists ASP.NET_SessionId] }{ set SessionId [HTTP::cookie ASP.NET_SessionId] else { set SessionId [HTTP::uri findstr "ASP.NET_SessionId=" 17 24] }
- JRahm
Admin
I am setting the persistence on the first server response for clients who disable cookies. For clients who enable cookies, is it better (read--more efficient) to persist them with cookie insert, or write the persistence for the jsessionid cookie into the rule I'm using to persist the cookie-disabled clients? If I stick with cookie insert, I can delete the persistence entry from the table for clients who return with cookies, and maintain the entries for clients who do not. If I use the jsessionid cookie, then I must maintain persistence entries for all clients. - Deb_Allen_18Historic F5 Account
- JRahm
Admin
The non-cookie persistence does not work unless I have oneconnect enabled. Is this by design? My rule:when HTTP_RESPONSE { if { [HTTP::cookie exists "JSESSIONID"] } { set trimID [lindex [split [HTTP::cookie "JSESSIONID"] "!" ] 0] if { [persist lookup uie $trimID] equals "" } { persist add uie $trimID 1800 log "added persistent entry $trimID for server [LB::server addr]" } else { log "continued sessionID $trimID for server [LB::server addr]" } } } when HTTP_REQUEST { if { [active_members MyPool] == 0 } { HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/myUri.html" } if { [HTTP::header exists "X-Forwarded-Host"] } { HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"] } if { not [HTTP::cookie exists "MyCookie"] } { set jsess [findstr [HTTP::uri] "jsessionid" 11 "!"] if { $jsess != "" } { persist uie $jsess 1800 log "Used URI, value is $jsess, server [LB::server addr]" } } else { log "used Cookie Insert, value is [HTTP::cookie "MyCookie"]" } }
- Deb_Allen_18Historic F5 AccountWithout OneConnect enabled, only the first request in a Keep-Alive connection is parsed for persistence data, so if multiple requests are sent on the same Keep-Alive connection, LTM will persist them all to the same destination as the first.
- Deb_Allen_18Historic F5 Accountfollow on post split to new topic: Click here
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