Forum Discussion
rjordan
Nimbostratus
Jul 30, 2010Setting the domain of a cookie
Up until now, we were able to handle all of our persistence needs with the default cookie persistence. Now we have an application running on www.foo.com and sub.foo.com. We need to maintain persistenc...
hoolio
Cirrostratus
Aug 03, 2010You could use the domain command to do this:
http://devcentral.f5.com/wiki/default.aspx/iRules/domain
[domain www.sub.my.domain.com 2] -> domain.com
You might want to check that the host header isn't an empty or an IP address first. Here is an untested example:
when HTTP_REQUEST {
if { [string match {*[a-zA-Z]*} [HTTP::host]]}{
set domain [domain [HTTP::host] 2]
} else {
set domain ""
}
}
when HTTP_RESPONSE {
Check if the persistence cookie exists in the response
if {[HTTP::cookie exists "BIGipServer[LB::server pool]"] and $domain ne ""} {
set the domain attribute on the persistence cookie
HTTP::cookie domain "BIGipServer[LB::server pool]" $domain
}
}
Aaron
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