Forum Discussion
wyuen_99269
Altostratus
May 07, 2015How to search a string for multiple values and replace with another string
Inserting cookie: PHPSESSID=eur026tal67g54keu6oj5gphh6; expires=Fri, 08-May-2015 13:23:10 GMT; path=/; domain= HttpOnly
Need code to strip "HttpOnly" or "httponly"
HTTP::header insert "Set-...
nitass
Employee
May 08, 2015Cookies are unable to be generated when having HttpOnly.
this is mine.
irule
root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
when HTTP_RESPONSE {
if { [HTTP::header exists "Set-Cookie"] } {
array unset cookielist
foreach cookievalue [HTTP::header values "Set-Cookie"] {
set cookiename [getfield $cookievalue "=" 1]
set namevalue ""
set newcookievalue ""
log local0. "CookieName = $cookiename ProxyPass"
log local0. "CookieValue = $cookievalue ProxyPass"
foreach element [split $cookievalue ";"] {
set element [string trim $element]
log local0. "Element = $element ProxyPass 1"
if { $namevalue equals "" } {
set namevalue $element
} else {
if { $element contains "=" } {
set elementname [getfield $element "=" 1]
set elementvalue [getfield $element "=" 2]
if { [string tolower $elementname] eq "domain" } {
set elementvalue [string trimright $elementvalue "."]
append elementvalue "."
}
append newcookievalue "; $elementname=$elementvalue"
} else {
append newcookievalue "; $element"
}
}
}
set cookielist($cookiename) "$namevalue$newcookievalue"
}
HTTP::header remove "Set-Cookie"
foreach cookiename [array names cookielist] {
log local0. "Remove CookieName = $cookielist($cookiename) ProxyPass"
HTTP::header insert "Set-Cookie" $cookielist($cookiename)
log local0. "Inserting cookie: $cookielist($cookiename)"
}
}
}
}
client
[root@bip8:Active:Standalone] config curl -I http://172.28.24.10
HTTP/1.1 200 OK
Date: Fri, 08 May 2015 06:42:12 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT
ETag: "41879c-59-2a9c23c0"
Accept-Ranges: bytes
Content-Length: 89
Content-Type: text/html; charset=UTF-8
Set-Cookie: PHPSESSID=eur026tal67g54keu6oj5gphh6; expires=Fri, 08-May-2015 13:23:10 GMT; path=/; domain=www.supportourtroopscanada.com.; HttpOnly
Set-Cookie: cookie1=value1; Path=/; HttpOnly
/var/log/ltm
[root@ve11c:Active:In Sync] config tail -f /var/log/ltm
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : CookieName = cookie1 ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : CookieValue = cookie1=value1; Path=/; HttpOnly ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = cookie1=value1 ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = Path=/ ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = HttpOnly ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : CookieName = PHPSESSID ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : CookieValue = PHPSESSID=eur026tal67g54keu6oj5gphh6; expires=Fri, 08-May-2015 13:23:10 GMT; path=/; domain=www.supportourtroopscanada.com.; HttpOnly ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = PHPSESSID=eur026tal67g54keu6oj5gphh6 ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = expires=Fri, 08-May-2015 13:23:10 GMT ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = path=/ ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = domain=www.supportourtroopscanada.com. ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Element = HttpOnly ProxyPass 1
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Remove CookieName = PHPSESSID=eur026tal67g54keu6oj5gphh6; expires=Fri, 08-May-2015 13:23:10 GMT; path=/; domain=www.supportourtroopscanada.com.; HttpOnly ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Inserting cookie: PHPSESSID=eur026tal67g54keu6oj5gphh6; expires=Fri, 08-May-2015 13:23:10 GMT; path=/; domain=www.supportourtroopscanada.com.; HttpOnly
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Remove CookieName = cookie1=value1; Path=/; HttpOnly ProxyPass
May 8 15:01:17 ve11c info tmm[15145]: Rule /Common/qux : Inserting cookie: cookie1=value1; Path=/; HttpOnly
I wanted to string the string "HttpOnly" or "httponly" out of the cookie line.
anyway, if you want, you may use string map to remove httponly (i.e. replace it with null).
set cookievalue [string map -nocase {"httponly" ""} $cookievalue]
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
