APM Time Based Cookie

Problem this snippet solves:

The iRule allows you to change the APM session based cookie to a Time based cookie. This allow sthe session to stay active even if the user closes the browser. The new time based cookie is set after the user log on to the system and will stay active until the expires time is reached.

Code :

when HTTP_REQUEST {
                
                set cookie_set 0
                set timeout_set 0
                #Checks to see if client passes back Cookies
   if {[HTTP::cookie exists "custom_timeout"]} {
                  set timeout_set 1
                }
    if {[HTTP::cookie exists "MRHSession"]} {  
                   set MRHSession [HTTP::cookie MRHSession]
                }
                if {[HTTP::cookie exists "LastMRH_Session"]} {
                                set LastMRH_Session [HTTP::cookie LastMRH_Session]
                    set LastMrh_cookie 1  
    }          
}

when HTTP_RESPONSE {
  
                #If the client has passed back cookies and timout_set is not set the iRule will reset the cookies with a 4 hour timeout.
                if {
                                ( not ($cookie_set equals 0)) ||
                                ( not ($timeout_set equals 1))
                } {
                                HTTP::cookie insert name "Chk_timeout" value "set"
                    HTTP::cookie expires "custom_timeout" "14400" relative
                                HTTP::cookie insert  name "MRHSession" value $MRHSession
                HTTP::cookie expires "MRHSession" "14400" relative
                }
                if {
                                ( not ($LastMrh_cookie)) ||
                                ($cookie_set != "0")
                } {
                                HTTP::cookie insert name "LastMRH_Session" value $LastMRH_Session
                HTTP::cookie expires "LastMRH_Session" "14400" relative
                                set cookie_set 0
                }
}
Published Jan 30, 2015
Version 1.0
  • Hi, what is the difference with a persistent cookie in Access Profile? The default behavior of a persistent cookie in profile is to synchronize cookie expiration time with session expiration time.