Forum Discussion
user1115_113077
Nimbostratus
Jun 25, 2011Help with Cookie Insertion
Hello,
Currently we're using the following on a vs,
when HTTP_REQUEST {
if { [HTTP:uri] starts_with "/clasee*"} {
pool class} ...
The_Bhattman
Nimbostratus
Jun 25, 2011Hi User1115,
In that case one of the ways you can do this is the following codes
This is for version 9.x.x
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [matchclass [IP::client_addr] eq $::class_ip] } {
HTTP::cookie insert name "class" value "class"
}
Choose a pool based on URI
if { [HTTP:uri] starts_with "/clasee*"} {
pool class
} else {
pool main
}
}
OR Using a switch statement
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [matchclass [IP::client_addr] eq $::class_ip] } {
HTTP::cookie insert name "class" value "class"
}
Choose a pool based on URI
switch -glob [string tolower [HTTP::uri]] {
"/clasee*" { pool class }
default { pool main }
}
}
If you are going to v10 then the code would like like the following
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [class match [IP::client_addr] equals "class_ip" } {
HTTP::cookie insert name "class" value "class"
}
Choose a pool based on URI
if { [HTTP:uri] starts_with "/clasee*"} {
pool class
} else {
pool main
}
}
OR Using a switch statement for v10
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [class match [IP::client_addr] equals "class_ip"] } {
HTTP::cookie insert name "class" value "class"
}
Choose a pool based on URI
switch -glob [string tolower [HTTP::uri]] {
"/clasee*" { pool class }
default { pool main }
}
}
I hope this helps
Bhattman
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