Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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

0