Forum Discussion
Deb_Allen_18
May 31, 2006Historic F5 Account
Extracting a specific Set-Cookie header in HTTP_RESPONSE
(This is a followup to this post: Click here)
How can I extract the value of a specific Set-Cookie header?
I'm trying to use a cookie for universal persistence, but I could not find a way to find the value of more than one Set-Cookie header in the server response.
It doesn't appear that the [HTTP::cookie names] works against Set-Cookie headers in the response, despite this post (Click here) regarding universal persistence which seems to indicate it will list the cookies being set in the server response.
I get a blank list when I do the same thing, which actually makes sense, since they are not cookies yet, just Set-Cookie headers.
So it seemed like I need to grab the Set-Cookie header instead, but if there are multipe cookies being set, I can't seem to extract anything but the first one with [HTTP::header Set-Cookie].
I was thinking maybe something like this:
while {[HTTP::header Set-Cookie]}{if...}
, but was not sure if that would iterate them all, or loop endlessly, or break prematurely if Set-Cookie headers are not contiguous or...?thoughts appreciated...
/deb
- Deb_Allen_18Historic F5 AccountThanks, Colin.
- JRahm
Admin
any update on this, Deb/Colin? - apara_5691
Nimbostratus
A little bit late but, this code works for me 😉
Regards!when HTTP_RESPONSE { First of all, we check if a Set-cookie header exists if { [HTTP::header count "Set-cookie" ] > 0 } { set all_set_cookies [HTTP::header "Set-cookie" foreach one_set_cookie $all_set_cookies { Whe are looking for a cookie named "myCookie" if { $one_set_cookie contains "myCookie" } { Whatever you want to do with "myCookie" ;) } } } }
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