uni
Sep 04, 2007Altostratus
Persistence using session cookies
I've read through a few of the articles on setting persistence based on the contents of a session cookie, and come up with the following:
when HTTP_REQUEST {
if { [HTTP::cookie exists "SESSIONID"] } {
if { persist lookup uie [HTTP::cookie "SESSIONID"] != "" } {
persist uie [HTTP::cookie "SESSIONID"] 600
}
}
}
when HTTP_RESPONSE {
if { [HTTP::cookie exists "SESSIONID"] } {
if { persist lookup uie [HTTP::cookie "SESSIONID"] == "" } {
persist add uie [HTTP::cookie "SESSIONID"] 600
}
}
}
The examples I've seen don't include tests for the prior existence of the persistence record as I have done above. Is it necessary to do so? i.e. if I attempt to add persistence that already exists, is it silently ignored, and if I attempt to use a persistence record that doesn't exist, is it silently ignored? If the "persist lookup" tests are not required, I expect it is more efficient to leave them out.
How do the timeouts work? I assume the "persist add" timeout starts a timer to clean up the persistence record. Does using the persistent record with "persist" extend the timer for the same period, and "persist" with a timeout extend the timer by the new amount?
What events can "persist add" be used in? It looks to me like it binds the persistence to the selected node, so can only be used once a server connection has been made, or maybe before in the LB_SELECTED event.