Forum Discussion
hooleylist
Jan 04, 2011Cirrostratus
Maybe something like this?
when RULE_INIT {
set static::session_cookie "my_session_cookie"
}
when HTTP_REQUEST {
Check if cookie exists in request
if {[HTTP::cookie $static::session_cookie] eq ""}{
set insert_cookie 1
} else {
set insert_cookie 0
}
}
when HTTP_RESPONSE {
Insert a cookie in the response if one wasn't present in the request.
Use the client IP:port plus unixtime.
Could use something random instead like an 8 digit psuedo random number: [format "%08d" [expr { int(100000000 * rand()) }]]
if {$insert_cookie}{
HTTP::cookie insert name $static::session_cookie value "[IP::client_addr]_[TCP::client_port]_[clock seconds]"
}
}
If you want to use this on multiple virtual servers and differentiate between them with the session ID, you could prepend the vs name using [virtual name].
Aaron