Forum Discussion

Joe_Curl_105786's avatar
Joe_Curl_105786
Icon for Nimbostratus rankNimbostratus
May 17, 2010

iRule - Insert Session Cookie

We are in need of keeping track of when someone logs into the application for the first time. We are wanting to do a session cookie insert in the iRule so we can track that. We need to do this in the iRule since we need to load balance the application using the jsession id. We have seen where you can do the cookie insert with a time setting, but we do not see anything about creating a session cookie. Is there a way to do this? Any other ideas for keeping track of http sessions in an iRule are also appreciated. Joe

3 Replies

  • Hi Joe,

     

     

    If the application is setting a jsessionid cookie, couldn't you use that to identify which server the client needs to be persisted to? There is an existing Codeshare example which does this:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/Weblogic_JSessionID_Persistence.html

     

     

    You can create a session cookie by setting the cookie without an expire time. This is the default for the HTTP::cookie insert command:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/http__cookie

     

     

    Aaron
  • Aaron,

     

     

    Thanks for the response back. We assumed that not setting an expire time would do that but wanted to make sure. The issue with using the jsession id is that sometimes the application needs to login and also sends an old jsession id in that request. Since it is there we would not know to redirect them to the login page. We have also discovered that the iPhone holds on to session cookies longer than we thought.

     

     

    Joe
  • You could also try standard cookie insert persistence if you want LTM to track the load balancing decision it makes over the course of the browser session.

     

     

    Aaron