Forum Discussion

mjohns2_184959's avatar
Oct 02, 2015

Cookie Persistence (iRule) Reset Timeout

We have a virtual, with several pools defined in it's iRule. The application owner has the application timeout users in 60 minutes of no activity. They've requested that the load balancer do the same, time out idle sessions after 60 minutes.

Our iRule times out users at 60 minutes of activity or no activity. Is there a way to either resend the cookie with a new timeout or reset the expire time of the existing cookie on the client?

Below is a sample of our iRule

when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
    “/example*”
    {
            pool VIPNAME1-POOLNAME
            persist cookie insert cookie "0d 00:60:00"
    }
    “/sample*”
    {
            pool pool VIPNAME-POOLNAME 
            persist cookie insert cookie "0d 00:60:00"
    }
}

}

Thanks MJ

3 Replies

  • So normally the cookie is inserted in only 1 response - you need the cookie inserted in every response so that it always expires in 60min. Let me know if this works;-

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            “/example*”
            {
                pool VIPNAME1-POOLNAME
            }
            “/sample*”
            {
                pool pool VIPNAME-POOLNAME 
            }
        }
        persist cookie insert cookie "0d 00:60:00"
        set cname "BIGipServer[LB::server pool]"
    
        if {[HTTP::cookie exists "BIGipServer[LB::server pool]"} {
             Save the current cookie value
            set cvalue [HTTP::cookie $cname]
        } 
    }
    
    when HTTP_RESPONSE {
       if {![HTTP::cookie exists $cname]} {
             If there is no cookie in this response already,  insert one
            HTTP::header insert Set-Cookie "$cname=$cvalue; Path=/; Max-Age=3600; HttpOnly
       }
    }
    
  • Check your cookie persistence profile, recent versions have the option to enable this feature there.