Joern_Oltmann
Jan 28, 2013Nimbostratus
Set cookie in http request AND response
Hi all,
this is my first Topic, so sorry if somthing wrong ;-)
I would like to set a cookie (if not set) in the http request. So the application see if the user are new.
The same cookie I would like to set in the http response (if not set). Erveryone an idea?
My first iRule, but not finished yet shows:
Rename a cookie by inserting a new cookie name with the same value as the original. Then remove the old cookie.
when HTTP_REQUEST {
Check if old cookie exists in request
if { [HTTP::cookie exists "_global"] } {
everything ok, cookie exists
} else {
TODO: create unique session
set new_session = [UnixTimeWithNanoSeconds]
Flag the request / session as new (for other systems)
HTTP::header insert "X-Global-Session" "New"
Insert new global cookie with session value
HTTP::cookie insert name "_global" value $new_session
}
}
Set cookie if a new Cookie was generated
when HTTP_RESPONSE {
TODO: check if new session
if { $new_session > 0 } {
insert new global cookie and transport it to the client
HTTP::cookie insert name "_global" value $new_session
reset state
set new_session = 0
}
}
Thanks for help
Joern