Andrea_Arquint
Oct 20, 2010Nimbostratus
cookie insertion
Hi
How can I set a cookie in the clients browser if he makes a request to a specific /folder/ ???
thanx
bb
when HTTP_REQUEST {
set uagent [string tolower [HTTP::header User-Agent]]
switch -glob [HTTP::host] {
if { [HTTP::uri] starts_with "/test" } {
HTTP::cookie insert name "ClassicView" value "mobile" path /
} else {
log local0. "no cookie set"
}
}
unset uagent
}
But the cookie is not set ???
I posted right before you...we need to do the cookie insert from the HTTP_RESPONSE event. Using it in the Request event inserts it between LTM and the pool members. I forgot my traffic flow for a second.
The example above your post should work. I can modify yours as well.
when HTTP_REQUEST {
set uagent [string tolower [HTTP::header User-Agent]]
switch -glob [HTTP::host] {
if { [HTTP::uri] starts_with "/test" } {
set cinsert 1
} else {
set cinsert 0
log local0. "no cookie set"
}
}
unset uagent
}
when HTTP_RESPONSE {
if { $cinsert eq 1 } {
HTTP::cookie insert name "ClassicView" value "mobile" path / }}
May I ask how you're using the uagent variable here? Is it for something separate from the cookie logic?