vADC Docs

HowTo: Delete Session Persistence records

by on ‎02-24-2013 07:20 AM - edited on ‎06-11-2015 02:32 PM by PaulWallace (2,201 Views)

Session Persistence records tend to be long-lived in Stingray Traffic Manager.  They become irrelevant when the client session completes (e.g. when it's pinned to a browser session cookie) and are eventually forgotten when Stingray's cache is full and the longest unused records are deleted.

 

The quick example illustrates how to pin a session persistence record to a TrafficScript-generated cookie that can be deleted on demand:

 

$url = http.getPath();

# We're only interested in .jsp pages
if( ! string.endswith( $url, ".jsp" ) ) break;

# Get the session persistence cookie
$cookie = http.getCookie( "MySession" );

# If the user hasn't got a cookie (i.e. first time in, or we've deleted the session persistence)

# create a new, random cookie.

if( ! $cookie ) {
   $rand = math.random( 0xfffffff ) . sys.time() . request.getRemoteIP();
   $cookie = string.hexencode( string.hashMD5( $rand ) );
   http.setResponseCookie( "MySession", $cookie );
}


if( $url == "/logout.jsp" ) {
   # Clear the cookie in the response, so that next time in we create a new one
   http.setResponseCookie( "MySession", "" );
}


# Persist on the value of the cookie

if( $cookie) {
  connection.setPersistenceKey( $cookie );
connection.setPersistence( "My Session Persistence Class" );
}

 

Read more

 

Contributors