REQUEST A DEMO

Automtically Logging Out Inactive Sessions in dtCl


Within the dtClient, it is possible for a user to stay logged in for an
indefinite period of time. But when you only have a limited number of
licences available this can be undesirable. I have written this code to
mimic the Clarify thick client functionality of releasing the license
(logging the user out) after an hour of inactivity.

When
you are using dtClient, the console screen automatically refreshes
itself (a default setting of two minutes). It is this code that keeps
the users session “alive” on the server even when the user is not
actively using the system. The purpose of this code is to detect that
only the console screen is refreshing, and to remove the user if this
continues for a specified amount of time.

The
modification to the dtClient code is very minimal. The first thing to
do is add the following lines into the global,asa in the specified
sections:

——————————————

function Application_OnStart()
{
// Global setting to determine whether or not to log out for inactivity
Application.Contents(“LicenseExpires”)= true;

// Idle time in minutes before logging out.
Application.Contents(“TimeToExpire”)=60;

// URL to load when dtClient times out
Application.Contents(“LoadPageOnExpire”)=”http://yourservername/dtClient“;
}

function Session_OnStart()
{
// Add current date/time to session
var set_time;
set_time=new Date();
Session.Contents(“LastUpdate”)=set_time.toString();
}

——————————————-

Finally
we add the code below to the top of the inc_page_init.asp located in
the include folder. We add the code in this page because all dtClient
pages access this file when they are opened.

———————————————-
<%
var allowTimeout;
var expiresIn;
var pageName;
var currentTime;
var lastUpdate;
var minutesIdle;
var sendToURL;

if (Application(“LicenseExpires”)) {
// Read the URL
pageName=Request.ServerVariables(‘PATH_TRANSLATED’).Item;

// Get the current date/time
currentTime=new Date();

//Check to see if the URL is the console
if (pageName.indexOf(“console”) < 0) {
// URL does not contain “console” so update our session date/time
Session(“LastUpdate”)=currentTime;
}

// Read the amount of times in minutes before logging out from the application variable
expiresIn=Application(“TimeToExpire”);

// Read our date/time and our URL
lastUpdate= new Date(Session(“LastUpdate”));
sendToURL=Application(“LoadPageOnExpire”);

// How many minutes since the last update? Subtracting the LastUpdate date from the current date/time returns the
// number of milliseconds difference. We multiply this by 1000 to get seconds and again by 60 to get minutes
minutesIdle = Math.round((currtime – lastupdate)/(60 * 1000));

// If the number of minutes since the last update are greater than or equal to our timeout value
if (minutesIdle >= expiresIn) {
//Close the session and use javascript to move to the URL we specified
Session.Abandon();
%>
<script language=”javascript”>
// If this is inside of a frame then remove frame then forward, otherwise just forward
if (self.parent.frames.length != 0) {
self.parent.location=”<%=sendToURL%>”;
} else {
location.href=”<%=sendToURL%>”;
}
</script>
<%
Response.End
}
}
%>


In the above code, I incorrectly wrote the line of code to set the
minutesIdle variable in the inc_page_int.asp. The line should read as
follows:

minutesIdle = Math.round((currentTime – lastUpdate)/(60 * 1000));

Gary Storey
Federated Systems Group