Hi,
i faced an issue when trying to share session data between VS:
here was my code:
when HTTP_REQUEST {
if {[session lookup uie {[IP::client_addr] any virtual}] eq ""} {
log local0. "no session data found"
session add uie {[IP::client_addr] any virtual} "1" 1800
} else {
log local0. "session data found "
}
}
Then if i look at my persistence record i can see that my persistence value is [IP::client_addr] -_-’
I did several manipulation and saw that by doing it through a variable it would work and without the {}
when HTTP_REQUEST {
set line "[IP::client_addr] any virtual"
if {[session lookup uie $line] eq ""} {
log local0. "no session data found"
session add uie $line "1" 1800
} else {
log local0. "session data found "
}
}
Is it some kind of issue ?
Thanks for your help!
I saw this behavior in v9.4.3 and v9.4.4
Out of curiosity i tried this iRule:
when HTTP_REQUEST {
set line "[IP::client_addr] any virtual"
if {[persist lookup uie {[IP::client_addr] any virtual}] eq ""} {
log local0. "no session data found"
persist add uie {[IP::client_addr] any virtual} 1800
} else {
log local0. "session data found "
}
}
and it works, so here the syntax is fine, it doesn’t work only for the session command
Hi
so should we use command “persist” instead of “session” if we want to store value for sharing between two VS?
- rk
No mandatory since my workaround works but i think it may be better to wait for an answer from Devcentral.
I opened a support case anyway i’ll keep you updated.
Hi,
it seems to be an expected behavior …
Here is the response coming from support:
The session command expects all of the data and associated “any virtual” commands to be a single argument; in other words, a list.
The documentation uses the most obvious and straight forward way of creating a list, which is to use curly braces ( {} ). However, Tcl deliberately does not expand variables inside curly braces, so the session command as it is written does not add the IP address as the key.
See DevCentral - An F5 Technical Community for additional details on TCL and braces..
There are two ways to make this work. The first is to use the “list” command to create the list:
set slist [list [IP::client_addr] any virtual] session lookup uie $slist
The second way is to use a string and let Tcl promote it to a list. This is what you are doing when you set the variable.
session lookup uie “[IP::client_addr] any virtual”
HTH
This also applies to the persist command.
In the comments section of that link, fancisfcm calls out the same solution.
"francisfcm writes:
To allow variable substituition for in = { [any virtual|service|pool] [pool ] }, double quotes should be used instead of braces."
Yes it must definitely apply to the persist command too
Thanks for your remark