Forum Discussion
William_Wright_
Nimbostratus
Dec 20, 2005Basic cookie session iRule
I need to create a basic iRule that keeps persistence based on JSESSION and load balances accordingly otherwise. I have tried all the standard persistence methods but it always goes back to defaulting to source IP. I have found quite a few example iRules but most of them get very involved. Can someone get me an example of how a basic iRule for session persistence using JSESSION would be??
Thank you
- Colin_Walker_12Historic F5 AccountHere's a simplified version of the rule given in this thread Click here
when HTTP_REQUEST { set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"] if { $jsess != "" } { persist uie $jsess } }
- William_Wright_
Nimbostratus
I did an ethereal trace and found that the JSESSIONID. here is what it looks like: - JRahm
Admin
That will strip jsessionid= (11 characters) out of the string so that only the session id is persisted on. - William_Wright_
Nimbostratus
I also need to put an else statement that uses a pool if the JSESSIONID does not exist. Where would I put that??? - Colin_Walker_12Historic F5 AccountThis should be pretty straight forward. There are literally hundreds of examples of this sort of thing in the forums if you look around a little. It's always best to use the search function or even just browse around to see if there are answers to the questions you have, as many people are working on or have worked on similar rules that can help each other with their experience.
when HTTP_REQUEST { set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"] if { $jsess != "" } { persist uie $jsess } else { pool yourPool } }
- William_Wright_
Nimbostratus
How can I log what the cookie name is or the cookie contents?? - Colin_Walker_12Historic F5 AccountYou might also want to check out askf5.com for some iRules documentation on the different commands like HTTP::cookie.
- William_Wright_
Nimbostratus
I am getting inconsistant results. Sometimes the persistence works and sometimes it does not. After using some ethereal traces I found that even using an iRule to do JSESSIONID persistence it also uses source port. Is there anyway to write a rule that will only look at the JSESSIONID and not the source port?? - unRuleY_95363Historic F5 AccountDo you mean the source port embedded in the JSESSIONID?
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