Jump to content

Refreshing page to keep session


dc_jt

Recommended Posts

Hi I am using the code below to refresh a page using javascript and ajax so that a user is never kicked out however I have had one user say they were kicked out. Is there any reason why their session may have expired? Could it be anything to do with their browser such as they dont have javascript enabled maybe?

 

function Ajax()
{
this.toString = function() { return "Ajax"; }

this.makeRequest = function(_method, _url)
{
	this.request = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
	this.request.open(_method, _url, true);
	this.request.send(_url);
}

this.checkReadyState = function(_id, _1, _2, _3)
{	
	switch (this.request.readyState)
	{
		case 1:
			if (_id != null) document.getElementById(_id).innerHTML = _1;
			break;
		case 2:
			if (_id != null) document.getElementById(_id).innerHTML = _2;
			break;
		case 3:
			if (_id != null) document.getElementById(_id).innerHTML = _3;
			break;
		case 4:
			return this.request.status;
	}
}
}

var oAjax = new Ajax();
var limit = 0;

function ajaxRefresh()
{
  if (limit==1)
  {
    //make background request
    oAjax.makeRequest('GET', '/sessionrefresh.php');
    limit = iMinutes * 60 + iSeconds;
  }
  else
  {
    limit--;
  }
  setTimeout("ajaxRefresh()",1000)
}

function beginAjaxRefresh()
{
  limit = iMinutes * 60 + iSeconds;
  setTimeout("ajaxRefresh()",1000)
}

var iMinutes = 5;
var iSeconds = 0;
beginAjaxRefresh();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.