ASP and Javascript session popup warning problem

Using ASP and Javascript to do the following.

A user logs into a site and a session is created, 20min by default. I have javascript on every page that sets a timer to load a function that pops up a confirm window 5 min before the session times out. On every page as well, I have asp writing the header to refresh by taking the session.timeout and adding a minute after to it, then refreshing the page, which will have the users page directed to the login page telling them their session has expired.

The problem I have is with the popup window, after it pops up and if the user does not click ok or cancel, the window is still there, and then when the page tries to refresh it crawls along for well over a few minutes, eventually refreshing the page and redirecting the browser to the main login page. If someone clicks ok/cancel during that time it immediately re-directs which is fine. I need a way to have the popup window close itself after the 5 min and let the refresh take place.

Here is the code for the window and how it's called. (the timeout is only set to 2seconds cause I don't like waiting for 5 min )

// Set the timeout for the page, then load the warning before timeout
var t
t=setTimeout( 'ShowTimeoutWarning();', 2000 );

function ShowTimeoutWarning ()
//declare variable agree
var agree
agree=window.confirm('You will be automatically logged out in five minutes unless you do something!\n If you click cancel your session will expire and you will be logged out!');
   if (agree)
      // user is at terminal, reload the window to keep the session alive
      return false;
      //close window and allow asp refresh to boot user to login page

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use this;

setTimeout('window.close()', 10000); // closes window after 10 seconds
NitestarzAuthor Commented:
I wish it was that easy :)

The function get's called after the first timer goes off. Then the window.confirm pops up. If the user does not click ok or cancel after a specified interval, I want the popup to close itself, then the refresh will take over. I've put the setTimeout inside the function and all it does is throw up the confirm box then if you click cancel or ok, then the timer triggers the next event, but it will not close the first popup.
Try putting the window.close event in the body tag of the popup;

<body onload(setTimeout('window.close()', 10000));>

Or something like that...  
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

NitestarzAuthor Commented:
Didden't think of that, unfortunately it does the same thing, the first window must be ok'd or canceled before the next timer can begin. Im wondering if there is a way to set a countdown timer for the window, if something = 0 then window.close, only thing is I don't know how to go about writing it. It would seem that the settimer would take care of that, since the function is called, a new settimer is loaded and then should close the window. Im thinking it's cause of the type of popup window it is, a javascript popup???
As you've seen, window.confirm doesn't provide a very good solution here, because when the popup is activated, all Javascript timers stop.  Instead, you need to create a custom window with buttons, which CAN be controlled programatically.

There are a lot of free Javascript controls out there you can use -- there's a nice turnkey control available at the Dynamic Drive site here:

It should be able to meet your needs.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NitestarzAuthor Commented:
Stanscott, what I was thinking was that javascript did stop the timers, and it looks like that's the case. Whipped up a quick popup window that loads another page and set's the timeout on that page along with buttons. The link you provided was something I was trying to do but couldn't find any good resources on that "style" of window. Thanks everyone!
I don't see in that link provided where it does a window.close()...

BTW, the close() event I specified is to be placed in the opened popup window.  It is possible that the function will not run due to the window being opened as a child by the parent, not sure but it's possible.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.