I want to display a java script confirmation box before browser session is timeout with message as "Your session is going to timeout in 2 mins. Do you want to extend session?", if user is clicked on "Ok" button within the session timeout period, session should be extend. If he didnot clicked on OK button within the session timeout period, the session should expire.

Can any one give any solution or sample code for this.

Thanks Inadvance,



I am explaining my requirement clearly once again.

I am creating a session when user successfully login to the site and user gets a form to input some data into database.

Assume that user entered data into some fileds and let the browser ideal and doing some other work in his/her system.

My requrement is, 2 mins before(after 13 mins) of session timeout(I set session timeout as 15 mins in web.config), user should get an alert as" Your session is about to timeout in 2 mins(at 12:30:20PM), Do you want to extend session timeout?" with OK and Cancel button.

If user clicked on OK button with in session timeout period(within 15th minute), session should expire to one more 15 minutes, but browser should not refresh.(If browser refreshed, all the values entered by the user, will be cleared.)

If user didnot clicked any button with in session timeout or user clicked Cancel button or user clicked on OK button after session timout, session should expire at 15th minute.

Please let me know if you require any other details.



I have posted this forum in some other site and got the solutions.


Would you mind to share this solution with us?