Forum Discussion
lbong_53781
Nimbostratus
Oct 02, 2009HTTP::COOKIE not working as expected
I am running LTM 10.0.1
I have the following iRule and run into some issues when there are multiple cookie variable in the header. The Rule seems to only look at the last "Cookie:" variable in the header. If "My_Cookie" is the last cookie statement in the header, it will work. But if its not, it will not see "My_Cookie".
when HTTP_REQUEST {
if {[HTTP::cookie exists "My_Cookie"]} {
if {[HTTP::cookie "My_Cookie"] equals "1"} {
use pool My_Pool
} else {
use pool My_Pool_2
}
} else {
use pool Other_Pool
}
}
I tried to send the following to the F5 to test the rule.
do echo && echo -n "$number ";GET -Ssed -H 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)' -H 'Cookie: TID=5555%2D51020900262051001033859%2D0' -H 'Cookie: My_Cookie=1' -H 'Cookie: CHOSEN_BANNER=1' -H 'Host: mysite.com' http://mysite.com/?test=$number
- hoolio
Cirrostratus
Can you add logging to the test rule and post the results when it fails? In a quick test, this functionality seemed to work okay:when HTTP_REQUEST { Insert some test headers HTTP::header insert header1 value1 HTTP::header insert header2 value2 Test the header exists command for both headers if {[HTTP::header exists header1]}{ log local0. "header1 exists" } else { log local0. "header1 does not exist" } if {[HTTP::header exists header2]}{ log local0. "header2 exists" } else { log local0. "header2 does not exist" } Loop through each header by name and log the name and value foreach header [HTTP::header names] { log local0. "$header: [HTTP::header values $header]" } }
- lbong_53781
Nimbostratus
Thanks for looking into this. - hoolio
Cirrostratus
Sorry... I misread your post. On 10.0.1, the cookie value seems to work:when HTTP_REQUEST { HTTP::cookie insert name cookie1 value value1 HTTP::cookie insert name cookie2 value value2 if {[HTTP::cookie exists cookie1]}{ log local0. "cookie1 exists" } else { log local0. "cookie1 does not exist" } if {[HTTP::cookie exists cookie2]}{ log local0. "cookie2 exists" } else { log local0. "cookie2 does not exist" } log local0. "Cookie names ([HTTP::cookie names])" foreach cookie [HTTP::cookie names] { log local0. "\[HTTP::cookie value $cookie\]: [HTTP::cookie value $cookie]" } }
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