Forum Discussion

Dmitriy_Tiper's avatar
Dmitriy_Tiper
Icon for Altostratus rankAltostratus
Aug 27, 2021

Need to delete specific cookie from client browser when APM session is closed

Hi,

 

I need to delete specific cookie from client browser when APM session is closed. I found https://devcentral.f5.com/s/question/0D51T00006i7cT0/hot-to-delete-a-particular-cookiejsessionid-when-accesssessionclosed-event-is-trigered but looking on ACCESS_SESSION_CLOSED description it loos like "The iRule commands which require a flow context (for e.g. TCP, HTTP and SSL commands) can not be used in this event".

 

Indeed, if I am trying iRule from other topic:

 

when ACCESS_SESSION_CLOSED {

HTTP::cookie expires "JSSIONID" 0 absolute

HTTP::cookie expires "LtpaToken2" 0 absolute

}

 

It gives me error "command is not valid in current event context ".

 

Any help will be greatly appreciated.

5 Replies

  • Hello Dmitriy.

     

    Try this code:

    when ACCESS_SESSION_CLOSED {
    	HTTP::header insert "Set-Cookie" "MyCookie=deleted;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/"
    }

     

    Regards,

    Dario.

  • Thank you for suggestion, Dario but it is the same problem. When I am trying to create suggested iRule, F5 tells me: command is not valid in current event context (ACCESS_SESSION_CLOSED)][HTTP::header insert "Set-Cookie" "MyCookie=deleted;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/"]

     

    It is pretty much aligned with what documentation says about ACCESS_SESSION_CLOSED event The iRule commands which require a flow context (for e.g. TCP, HTTP and SSL commands) can not be used in this event"

  • Still looking for the possible solution. Any help will be greatly appreciated.

  • Hi Dmitriy,

    Can you try this iRule?

     

    when CLIENT_ACCEPTED {
        set status 0
    }
     
    when ACCESS_SESSION_CLOSED {
        set status 1
    }
     
    when HTTP_RESPONSE_RELEASE {
        if { $status } {
            HTTP::cookie expires "JSSIONID" 0 absolute
            HTTP::cookie expires "LtpaToken2" 0 absolute
        }
    }