Forum Discussion
Chris_G_Davis_1
Nimbostratus
Dec 18, 2008JSESSIONID Persistence
I'm trying to persist off a JSESSIONID cookie generated by the WebLogic Application Server however the follow iRule isn't working.
-------------
when HTTP_REQUEST { ...
hoolio
Cirrostratus
Jan 02, 2009Hi Chris,
There are a few possible issues with the Codeshare example:
1. The cookie name for HTTP::cookie is case sensitive. So [HTTP::cookie JSessionID] won't match a cookie named jsessionid or JSESSIONID. I believe that the jsessionid name is always in lower case, whether set in the path or a cookie name.
2. findstr is also case sensitive.
3. The format for the jsessionid in the URI is /path/to/object.ext;jsessionid=jsessionid_value or with a query string /path/to/object.ext;jsessionid=jsessionid_value?param=param_value. So using findstr with a terminator of ; won't work as expected. If you were checking the URI with a terminator, it should be the ? which starts the query string. Considering the jsessionid, if present, will always be at the end of the path, you can avoid dealing with a terminator by using HTTP::path insted of HTTP::uri.
4. The findstr command needs to account for the = in jsessionid=12345...., so it should be [findstr [HTTP::path] "jsessionid=" 11]
Can you try this example which addresses the above points? If you run into problems, please check the /var/log/ltm log file for debug output. Once you're done testing, youc can comment out the log statements. If it does work, please reply so we can update the Codeshare example.
Thanks,
Aaron
when HTTP_REQUEST {
Log details for the request
log local0. "[IP::client_addr]:[TCP::client_port]: Request to [HTTP::uri] with cookie: [HTTP::cookie value jsessionid]"
Check if there is a jsessionid cookie
if { [HTTP::cookie exists "jsessionid"] } {
Persist off of the cookie value
persist uie [HTTP::cookie "jsessionid"]
Log that we're using the cookie value for persistence and the persistence key if it exists.
log local0. "[IP::client_addr]:[TCP::client_port]: Used persistence record from cookie: [persist lookup uie [HTTP::cookie "jsessionid"]]"
} else {
Parse the jsessionid from the path (URI minus the query string)
set jsess [findstr [HTTP::path] "jsessionid=" 11]
Use the jsessionid from the path for persisting
if { $jsess != "" } {
persist uie $jsess
Log that we're using the path jessionid for persistence and the persistence key if it exists.
log local0. "[IP::client_addr]:[TCP::client_port]: Used persistence record from path: [persist lookup uie $jsess]"
}
}
}
when HTTP_RESPONSE {
Check if there is a jsessionid cookie in the response
if { [HTTP::cookie exists "jsessionid"] } {
Persist off of the cookie value
persist add uie [HTTP::cookie "jsessionid"]
log local0. "[IP::client_addr]:[TCP::client_port]: Added persistence record from cookie: [persist lookup uie [HTTP::cookie "jsessionid"]]"
}
}
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