I used the following code for session time out in idle state window.
after a minute popup will arise, if user didn't respond alert message within 2 minuts session will timeout .
firefox it's working fine.
But IE auto timeout in 2 minuts is not working , if user is not responding the alert within 2 minutes, i want the page has logout automatically.

code:

setTimeout('firstalert()',100000)

function firstalert()
{  
InitializeTimer();
if(confirm('I have not heard from you for a while. I can extend your connection 1 more minute \n(For your security protection, your connection will close,If there is no activity within 1 minute) \n would you like to me extend your connection time? \n'))
  {
       setTimeout('firstalert()',100000);                
       StopTheClock();
 }else
  {
    secondalert();            
  }
}

function secondalert()
{  
  window.location='login.php?logout&msg=Your session has ended due to inactivity. Please log back in to continue working'
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 120;
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        secondalert();

    }
    else
    {
        self.status = secs
        secs = secs - 1       
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

Please put your code inside [ code ] tags, so the indenting is preserved.

setTimeout('firstalert()',100000)

function firstalert()
{  
InitializeTimer();
if(confirm('I have not heard from you for a while. I can extend your connection 1 more minute \n(For your security protection, your connection will close,If there is no activity within 1 minute) \n would you like to me extend your connection time? \n'))
  {
       setTimeout('firstalert()',100000);                
       StopTheClock();
 }else
  {
    secondalert();            
  }
}

function secondalert()
{  
  window.location='login.php?logout&msg=Your session has ended due to inactivity. Please log back in to continue working'
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 120;
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        secondalert();
        
    }
    else
    {
        self.status = secs
        secs = secs - 1       
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.