Forum Discussion
transfer values between sessions
Hello, I need transfer value between different client requests (sessions?). First I used cookie (e.g. cookie name "cookie-a"), but value of this cookie should be not visible on client site. I have other cookie (e.g. "cookie-b") based on it I can pair bot connections.
In first connection I need store value (before stored in cookie-a) on big-ip. In second connection I need read this value.
I can use session or table, but based on documentation it's not clear for me. https://devcentral.f5.com/articles/the101-irules-101-variables https://devcentral.f5.com/wiki/iRules.session.ashx https://devcentral.f5.com/wiki/iRules.table.ashx
what is better choose - session or table (I'm not familiar with both of them). where are more details about for session?
I have two apps (/server1.txt and /server2.txt) between this I need transfer value. In my lab I have three clients (different browsers on the same pc - FF, IE, EDGE). when I try to use 'session' (see code below) it is working but I'm not sure if this is correct code.
exists any better solution of this?
here is my code:
when HTTP_REQUEST {
switch [HTTP::uri] {
"/server1.txt" {
random value for client session (based on cookie 'cookiename')
set uid [clock seconds]
session add sticky cookiename $uid 30
if { [HTTP::cookie exists cookiename] } {
session add simple [HTTP::cookie value cookiename] $uid 30
}
}
"/server2.txt" {
read of value in another client connection (http request)
it is working but I'm not sure if it's best solution
if { [HTTP::cookie exists cookiename] } {
set value [session lookup simple [HTTP::cookie value cookiename]]
} else { set value "undefined" }
HTTP::respond 200 content "this is uid='$value'" "content-type" "text/plain" "Connection" "close"
event HTTP_REQUEST disable
}
}
martin
1 Reply
- Leonardo_Souza
Cirrocumulus
https://devcentral.f5.com/wiki/irules.table.ashx
"The table command (like the session command) is a way to access the session table. The table command is a superset of the session command, with improved syntax for general purpose use. Please see the table command article series for detailed information on its use."
I had an idea that table command was deprecated, but I can confirm that. Anyway, they do the same work.
iRule looks ok, and using session table is the correct option. Just a small change, you dont need the event command.
https://devcentral.f5.com/wiki/irules.http__respond.ashx
"The BIG-IP will send the response as soon as the current iRule event completes, so you cannot alter the response in other HTTP iRule events."
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