Forum Discussion
gbbaus_104974
Sep 11, 2011Historic F5 Account
Set-Cookie in Response, based on Requested URI
Hi Guys
I am trying to set a cookie in a HTTP_RESPONSE, but only when the HTTP_REQUEST is to a specific HTTP::uri
To set a cookie on all http responses is easy, for example:
...
nitass
Employee
Sep 11, 2011[root@Edelweiss:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.17.17:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@Edelweiss:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set flag 0
if {[string tolower [HTTP::uri]] equals "/my.policy"} {
set flag 1
}
}
when HTTP_RESPONSE {
if {$flag} {
HTTP::cookie insert name "Cookie_Name" value "ClientDetectedtrue"
}
}
}
[root@Edelweiss:Active] config curl -I http://172.28.17.17/
HTTP/1.1 200 OK
Date: Sun, 11 Sep 2011 10:53:28 GMT
Server: Apache/2.0.59 (rPath)
Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT
ETag: "667a-67-cfb682c0"
Accept-Ranges: bytes
Content-Length: 103
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
[root@Edelweiss:Active] config curl -I http://172.28.17.17/my.policy
HTTP/1.1 404 Not Found
Date: Sun, 11 Sep 2011 10:53:34 GMT
Server: Apache/2.0.59 (rPath)
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
Set-Cookie: Cookie_Name=ClientDetectedtrue;
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