Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9028723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:03:48+00:00 2026-06-16T07:03:48+00:00

I’m working with some pretty old code and the following is being used to

  • 0

I’m working with some pretty old code and the following is being used to monitor session status. If the user is inactive for X minutes (determined by check_session.php), they are logged out.

The server side stuff works fine. Actually, the existing javascript appears to work OK as well, but looks like it needs cleaning up.

Here’s the existing javascript:

function checkSessionStatus() 
{ 
    session_http.open('GET', '/check_session.php', true); 
    session_http.onreadystatechange = handleSessionHttpResponse; 
    session_http.send(null); 
}

function handleSessionHttpResponse() 
{ 
    if (session_http.readyState == 4) 
    { 
        results = session_http.responseText; 
        if (results == 'inactive') 
        {
            window.location='/logout.php';
            document.getElementById('session_divbox').innerHTML = results; 
        }
    }
}

function get_session_HTTPObject() 
{
    var xml_session_http; 
    if (!xml_session_http && typeof XMLHttpRequest != 'undefined') 
    { 
        try 
        { 
            xml_session_http = new XMLHttpRequest(); 
        } 

        catch (e) 
        { 
            xml_session_http = false; 
        } 
    } 
    return xml_session_http; 
} 
var session_http = get_session_HTTPObject(); 

function init_page_header() 
{
    window.setInterval( 'checkSessionStatus();',  30000);
}

This seems incredibly long for what it is doing.

I am still learning jquery and am able to do some basic ajax calls like this one, which places a returned value in a div:

$(document).ready(function() 
{
    $('#users_online').load('/show_users_online.php');
    var refreshId = setInterval(function() 
    {
        $('#users_online').load('/show_users_online.php');
    }, 2000);
    $.ajaxSetup({ cache: false });
});

The issue with the first bit of code is that it returns a value of ‘inactive’, which is then acted on by the client (window redirect).

Is it possible to do this in Jquery without winding up with dozens of lines of code? I may already know how to do this and am not seeing the forest for the trees — some guidance here is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:03:49+00:00Added an answer on June 16, 2026 at 7:03 am

    Even if its very vampiric question style, should look like

    $.get('/check_session.php', function( data ) {
        if( data === 'inactive' ) { 
            window.location='/logout.php';
            document.getElementById('session_divbox').innerHTML = data;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.