// include this page to keep a session alive.  make sure a file called
// keepalive.php exists in the same directory as the calling page


var req;

function keepAlive() 
{
  // url to the keepalive page.  this should be a page in the same environment
  // as the session you are trying to preserve
  var url = "../keepalive.php";
  
  if (window.XMLHttpRequest) 
  {
    req = new XMLHttpRequest();
    req.onreadystatechange = processReqChange;
    req.open("GET", url, true);
    req.send(null);
  } 
  else if (window.ActiveXObject) 
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(req)
    {
      req.onreadystatechange = processReqChange;
      req.open("GET", url, true);
      req.send();
    }
  }
}

function processReqChange() 
{
  if(req.readyState==4 && req.status==200)
  {
    //alert('keepalive counter = ' + req.responseText);
    setInterval(keepAlive, 300 * 1000); //  1000 = 1 second
  }
}


// start the function
setInterval(keepAlive, 300 * 1000); // 1000 = 1 second