Forum Discussion

IT_Support_5777's avatar
IT_Support_5777
Icon for Nimbostratus rankNimbostratus
Sep 28, 2007

Cookie Peristence ASP Session ID

I would like to get some help with the following iRule:

 

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "ASP.NET_SessionId"] } {

 

persist add uie [HTTP::cookie "ASP.NET_SessionId"]

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "ASP.NET_SessionId"] } {

 

persist uie [HTTP::cookie "ASP.NET_SessionId"]

 

}

 

}

 

 

this looks at the ASP.NET session ID cookie and directs the LTM to send traffic back to the responding server, which is critical for our application. But we have a mixture of ASP and ASP.NET servers and I need the same thing done there. ASPSESSIONID is not so easy though...

 

 

We need to be able to do the same thing with the ASP sites as is done with the ASP.NET sites.

 

 

The problem is, the ASPSESSIONID cookie changes. It has what looks like a unique identifier on the end of the string. Two examples are given below from two different servers:

 

 

HTTP/1.1 200 OK

 

Date: Fri, 28 Sep 2007 14:44:30 GMT

 

Server: Microsoft-IIS/6.0

 

X-Powered-By: ASP.NET

 

Content-Length: 3080

 

Content-Type: text/html

 

Expires: Thu, 27 Sep 2007 22:04:30 GMT

 

Set-Cookie: ASPSESSIONIDSCSTRBCS=ADFSGDLOACOMNHJFKAHDEGEEFD; path=/

 

Cache-control: private

 

 

 

 

HTTP/1.1 200 OK

 

Date: Fri, 28 Sep 2007 14:54:05 GMT

 

Server: Microsoft-IIS/6.0

 

X-Powered-By: ASP.NET

 

Content-Length: 3080

 

Content-Type: text/html

 

Expires: Thu, 27 Sep 2007 22:14:05 GMT

 

Set-Cookie: ASPSESSIONIDQCDQSDAA=KAJBFABCDFDSFGDJKPEPPNFK; path=/

 

Cache-control: private

 

 

 

 

Is there any way to capture these? it looks as though I need to be able to parse the variable to do some logic.

 

 

7 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    There's a codeshare example addressing this issue:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/ASP_SessionID_Persistence.html (Click here)

     

     

    HTH

     

    /deb

     

  • Marcus_Slawik_8's avatar
    Marcus_Slawik_8
    Historic F5 Account
    Hi,

     

     

    maybe you also want to take a look at this thread. I struggeld with the same problem a while.

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=7303&view=topic

     

     

    schwiddy
  • thank you. I seem to be having issues implementing your solutions. the ASPID variable is empty most of the time.

     

     

    I am trying to list all of the cookies and I don't get much there either.

     

     

  • Marcus_Slawik_8's avatar
    Marcus_Slawik_8
    Historic F5 Account
    Did you try to put a OneConnect profile on the VS using a /32 mask?

     

     

    schwiddy
  • Here is a pretty concise summary from Unruley:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=12911

     

     

     

    The LB_SELECTED event is only fired when a load-balancing decision is made. And of course, persistence only plays a factor when the load-balancing decision is made.

     

     

    As a side effect of OneConnect, load-balancing will occur on every request. However, without OneConnect, load-balancing only occurs when the pool changes. Any subsequent requests that happen to go to the same pool will stay connected to the last pool member.

     

     

    So, you have two ways you can change this behavior: 1) Add OneConnect; 2) at the beginning of HTTP_REQUEST call LB::detach.

     

     

     

     

    Aaron
  • ok, thanks. I will check it out. the issue with our application is that once a session has started, it *cannot* be load-balanced. it must continue to send to the original server until the session ends.