Forum Discussion

Russell_McGinni's avatar
Russell_McGinni
Icon for Nimbostratus rankNimbostratus
Jan 21, 2009

Implement sticky sessions for a specific uri in VIP

I have a VIP that handles all traffic to a certain domain, however within that domain i have a specific ASP.Net application that uses Session Management and therefore I need to specifically provide a sticky session solution for just that uri

 

 

What i have is... but obviously not working... any help would be appreciated.

 

 

Thanks

 

 

when RULE_INIT {

 

set ::debug 1

 

set ::myval 0

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "TIMECLOCKF5"] } {

 

set cli [IP::remote_addr]:[TCP::remote_port]

 

set SessionId [HTTP::cookie ASP.NET_SessionId]

 

if { $SessionId != "" } {

 

persist uie $SessionId 1800

 

}

 

} elseif { [string tolower [HTTP::uri]] starts_with "/timeclock/" } {

 

set $::myval 1

 

}

 

}

 

 

when HTTP_RESPONSE {

 

if {$::myval} {

 

HTTP::cookie insert name "TIMECLOCKF5" value "testing"

 

set SessionId [HTTP::cookie ASP.NET_SessionId]

 

if { $SessionId != "" } {

 

persist add uie $SessionId 1800

 

}

 

}

 

}

2 Replies

  • You could take a look at the ASP session ID codeshare example to start with:

     

     

    ASP Session ID Persistence (Click here)

     

     

    Also, you're using a global variable $::myval to track whether to use persistence. A global variable is accessible and modifiable across all TCP connections, so one connection could overwrite the value from another. If you replace $::myval with $myval, it would be specific to that TCP connection. A local variable is available in all events across the same connection.

     

     

    Aaron
  • Posted By hoolio on 01/22/2009 6:39 AM

     

     

    You could take a look at the ASP session ID codeshare example to start with:

     

     

    ASP Session ID Persistence (Click here)

     

     

    Also, you're using a global variable $::myval to track whether to use persistence. A global variable is accessible and modifiable across all TCP connections, so one connection could overwrite the value from another. If you replace $::myval with $myval, it would be specific to that TCP connection. A local variable is available in all events across the same connection.

     

     

    Aaron

     

     

     

    I am a little bit of a novice when it comes to iRules, but i did try the codeshare example... i couldnt layer on a filtering mechanism that turned on the persistence only for a specific uri. It seems like the HTTP::uri value is not available in the HTTP_RESPONSE event handler (which is where you add the "session" to the persistence table).

     

     

    Additionally from further reading it seems that i can only have sticky session persistence if i have a persistence profile defined on the VIP, but then i get sticky sessions for the entire site that the VIP is supporting.

     

     

    Thanks for your input, more would be greatly appreciated.