tags:

views:

88

answers:

1

I'm trying to implement an automatic timeout inside of an existing PHP application.

My goal is to have the system notify the user 15 seconds before the automatic timeout is set to occur and give them the opportunity to 'reset' the timeout timer.

I'm using jQueryUI bits as a part of all of this.

This chart may help describe what I'm trying to do.

I have a working timer and notification in place. What I'm looking for is the loop of Get prompted for auto logout -> cancel auto logout -> restart timer -> Get prompted for auto logout. (It's what's in red on my chart.)

Are there any good, existing options for me to do this?

Here's what I have so far, but I think I'm stuck...

window.setTimeout(function() {
    $('#timeOutNoticeMsg').css('color', '#000000');
    $("#timeOutDialog").dialog({ 
        bgiframe: true,
        modal: true,
        resizable: false,
        draggable: false,
        buttons: { 
            "Cancel Logout": function() { 
                $(this).dialog("close"); 
                window.clearTimeout(timeoutHandle);
            }
        },
    });
},  103000);

var timeoutHandle = window.setTimeout(function() {
    window.location.href = 'logout.php?w=1';
}, 115000);
A: 

I would include a boolean variable in the "Cancel Logout" function:

       "Cancel Logout": function() { 
            $(this).dialog("close"); 
            window.clearTimeout(timeoutHandle);
            logMeOut = false;
        }

and then make the logout function dependent on that variable:

var timeoutHandle = window.setTimeout(function(logMeOut) {
if( logMeOut == true )
{    
    window.location.href = 'logout.php?w=1';
}, 115000);

Please note that I'm not a jQuery expert, and I DO NOT vouch for the pseudocode above. Figure out the syntax yourself.

eykanal
With a little bit of tweaking it's working....Thanks for the help
Jason