tags:

views:

13

answers:

0

Hi below is the code i'm using to extend the session time. For the first time pop up comes and when i clik ok session time is also extend but popup never comes up again when the session is expiring for the second time etc. Can any one correct me

why the setTimeout is not invoking ShowSessionWarning for second time.

function showSessionWarning()
{

if(window.name=="") I'm checking window.name because if I don't check it opens the pop up in all pages where common js file is refered
{
client = window.open("","SessionTimeOutWarning","location=1,status=1,scrollbars=no,width=200,height=200");

var html = "<input type=button value='   OK ' onClick='javascript:window.opener.onOk()'/><br>";
html += "<input type=button value='   Cancel ' onClick='javascript:window.opener.onCancel()'/>";



client.document.write(html);

TIMEOUT_TIMES=1000*60
setTimeout("onSelfTimeout()", TIMEOUT_TIMES);
}

}

var isOkCancelClicked = false;

function onSelfTimeout()
{

 if(isOkCancelClicked == false)
 {

  if(client != null)
   client.close();
  document.location.href = document.location.href;// refreshing the self window. and if session already timeout it will take you to login page.

 }
}

function onOk()
{
 if(client != null)
  client.close();
 isOkCancelClicked = true;
 // AjAX CALL  A DUMMY SERVER TRIP TO REFRESH THE SESSION 
 refreshTimeAJAX(window.location.protocol + "//" + window.location.host + "/Websystem/" + "/forms/frmTimeout.aspx");
}
function onCancel()
{
 if(client != null)
  client.close();
 isOkCancelClicked = true; 
         document.getElementById('btnLogoff').click();


}

TIMEOUT_TIME=2000 * 60
setTimeout("showSessionWarning()",TIMEOUT_TIME );// This value should be server session timeout -1 minute. 
var reqXMl;
function refreshTimeAJAX(url)
 {
 if(window.ActiveXObject)
 {

 reqXMl=new ActiveXObject("Microsoft.XMLHTTP");
 if(reqXMl)
 {
 reqXMl.onreadystatechange= handleSesssionRefreshResponse;
 reqXMl.open("POST",url,true);
 reqXMl.send();
 }
 }
 else
 {
 alert("your browser doesn't support AJAX");
 }  
}
function handleSesssionRefreshResponse()
{


}