Forum Discussion
Robert_47833
Dec 21, 2011Altostratus
how to use foreach
when HTTP_RESPONSE {
set cjj [HTTP::cookie names]
foreach cjjcookie $cjj {
if {$cjjcookie == "how to add 4 cookie name here"
}
{ Do nothing.
}
else {
HTTP::cookie secure $cjjcookie enable
}
}
}
I have 4 cookie names need to be specified in ""
cookie1
cookie2
cookie3
cookie4
- nitassEmployee
[root@ve1023:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_RESPONSE { foreach cjjcookie [HTTP::cookie names] { if {[class match -- $cjjcookie equals unsecure_cookie]} { Do nothing. } else { HTTP::cookie secure $cjjcookie enable } } } } [root@ve1023:Active] config b class unsecure_cookie list class unsecure_cookie { { "cookie1" "cookie2" "cookie3" "cookie4" } } [root@ve1023:Active] config curl -I http://200.200.200.101 HTTP/1.1 200 OK Date: Wed, 21 Dec 2011 07:18:11 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT ETag: "4183e4-3e-9c564780" Accept-Ranges: bytes Content-Length: 62 Set-Cookie: cookie1=1111; path=/ Set-Cookie: cookie2=2222; path=/ Set-Cookie: cookie3=3333; path=/ Set-Cookie: cookie4=4444; path=/ Set-Cookie: cookie5=5555; path=/ Connection: close Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config curl -I http://172.28.19.79 HTTP/1.1 200 OK Date: Wed, 21 Dec 2011 07:18:17 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT ETag: "4183e4-3e-9c564780" Accept-Ranges: bytes Content-Length: 62 Set-Cookie: cookie1=1111; path=/ Set-Cookie: cookie2=2222; path=/ Set-Cookie: cookie3=3333; path=/ Set-Cookie: cookie4=4444; path=/ Set-Cookie: cookie5=5555;secure; path=/ Connection: close Content-Type: text/html; charset=UTF-8
- Robert_47833Altostratusif {[class match -- $cjjcookie equals unsecure_cookie]} {
- nitassEmployeeI am confused by this part.what is the orginal code?what do you not understand? i just took it from class wiki.
- Robert_47833Altostratusoh,I got it ,hehe
- Robert_47833Altostratusoh,I got it ,hehe
- nitassEmployee"--" above betweet match and $cjjcookie should be removednot really. it is safe to put there.
- Colin_Walker_12Historic F5 AccountThere are actually several people that suggest using options terminators such as the -- in the class command. In particular when the next argument is a variable it can help ensure that nothing gets misinterpreted. I haven't made it a habit yet, but it certainly doesn't harm anything.
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