Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

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

Dmitriy_Tiper
Altostratus
Altostratus

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 5

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.

Regards,
Dario.

Dmitriy_Tiper
Altostratus
Altostratus

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"

Dmitriy_Tiper
Altostratus
Altostratus

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
    }
}

 

 

Dmitriy_Tiper
Altostratus
Altostratus

HI Enes,

 

Thank you for suggestion. I will look into your suggestion.