Forum Discussion
Joern_Oltmann
Nimbostratus
Jan 28, 2013Set 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.
...
Kevin_Stewart
Employee
Jan 29, 2013Expanding on Aaron's recommendation, I typically use the concatenation of two AES functions to return a unique ID:
Ex.
set session_key "[string range [AES::key 128] 15 end][string range [AES::key 128] 15 end]"
And here's something that might work for you:
when HTTP_REQUEST {
if { not ( [HTTP::cookie exists _global] ) } {
set session_key "[string range [AES::key 128] 15 end][string range [AES::key 128] 15 end]"
HTTP::header insert "X-GLOBAL-Session" "New"
HTTP::cookie insert name "_global" value $session_key
}
}
when HTTP_RESPONSE {
if { [info exists session_key] and $session_key ne "" } {
HTTP::cookie insert name "_global" value $session_key
unset session_key
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects