Forum Discussion
Replacing JESSIONID in the URI with contents of JSESSIONID cookie
Gang,
I have an issue where end-users are saving the post-authentication login page to an application as a Favorite, which also stores the JSESSIONID in the URI. When they go back to use that favorite, the JSESSIONID in the URI no longer exists, but the browser goes into an infinite loop looking for that particular URI. An HTTPWatch shows that there is a new JSESSIONID cookie set upon the initial connection to the server, so I'm thinking that I could do a simple compare between the Cookie and the URI. If there's a difference, I would like to replace the JSESSIONID URI information with the JSESSIONID cookie information.
URI example: http://crapplication/Program/j_security_check;jsessionid=9e934f9330d5081e34ce607b478a8e32dd9b0297dbb8.e34Qc3aObxiNe3aNbNyLax8Rby0
Cookie example: JSESSIONID=c15c1c5fb45f84a79864396e14eecb1d4b6150259e7972a06077d7aa16a55318.e34Mc3uNbN4Oci0LchaNa30QahiOe0; path=/Program
Any advice/tips are greatly appreciated.
Thanks.
Joe
3 Replies
- Kevin_Stewart
Employee
Something like this perhaps:
when HTTP_REQUEST { set j_uri [findstr [string tolower [HTTP::uri]] ";jsessionid=" 12] if { ( $j_uri ne "" ) and ( [HTTP::cookie exists JSESSIONID] ) } { if { $j_uri ne [HTTP::cookie value JSESSIONID] } { set newuri [string map "$j_uri [HTTP::cookie value JSESSIONID]" [HTTP::uri]] HTTP::redirect "http://[HTTP::host]$newuri" } } }Admittedly this is a crude example. I wasn't sure exactly how the jsessionid is formatted in the URI (part of the path, a query string value), or what (if any) values were after it and how they are delimited. Ultimately you'll need to tweak the findstr function to extract the jsessionid value from the URI. If the jsessionid value in the URI doesn't match the JSESSIONID cookie value, create a new URI by replacing the original value with the cookie value and then redirect the user to the new URI (with matching cookie).
- Joe_Erchul_4263
Nimbostratus
Kevin,
Nice solution. In looking at this, I assume that the JSESSIONID cookie value that will get inserted into the URI will also include ";path=/Program". Any ideas on how I can strip that off within the same iRule?
Thanks.
Joe
- Kevin_Stewart
Employee
The [HTTP::cookie value JSESSIONID] command should not contain the path or any other value other than the ID string. The cookie is coming from the client, so this information wouldn't be in the cookie header anyway. To test, add this line to the iRule:
log local0. [HTTP::cookie value JSESSIONID]
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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