Forum Discussion
How to read (get) cookie expiry value?
Hi- the iRule documentation specifies that, on HTTP_RESPONSE, one can get (or set) the value of a cookie expiry.
https://devcentral.f5.com/wiki/iRules.HTTP__cookie.ashx
I'm essentially trying to read the expiry value of a specific cookie, and perform logic based on the expiry value I obtain. For instance, within an HTTP_RESPONSE block trying to log a specific cookie expiry value:
set expires [HTTP::cookie expires "myCookie"]
log local0. "Cookie myCookie expires in: $expires"
Regardless of attempting in HTTP_REQUEST or HTTP_RESPONSE, I am unable to actually pull the value of the cookie expiry and set it to a variable..
Could anyone help point me in the right direction? I have no issues reading the value or determining the existence of a cookie itself.. but reading other attributes is not working for me.
Huge thanks in advance.
1 Reply
- Jeff_Maddox_394Historic F5 Account
Make sure when testing, all cookies are cleared. The expiry will appear in the server response that initially sets the cookie, but should not be in subsequent responses. Make sure in the testing, that particular response is being captured.
I am able to get this to work on a test page with the following:
when HTTP_RESPONSE { if {[HTTP::cookie exists "NID"] } { set expires [HTTP::cookie expires "NID"] log local0. "$expires" } }Log output:
bigip1 info tmm[10062]: Rule /Common/cookie_log : 1506041117
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
