I have write some javascript code in my application to prevent sessions timeouts for a specific type of user. The timeout is controlled by server. How shuld I do this?
Asked
Active
Viewed 3,038 times
-2
-
We need more information about the server, I think. Are you writing server code as ASP? JSP? PHP? etc. – Chris Forrence May 17 '13 at 18:42
1 Answers
4
Make a call to the server that hits some page that updates the session.
function ping() {
var img = new Image();
img.src = "somePage.php?ts=" + (new Date()).getTime();
window.setTimeout(ping,60*1000);
}
You could make an an Ajax call instead of an image request.

epascarello
- 204,599
- 20
- 195
- 236
-
You can ask to user(by confirm) here if he want to update or not (be idle)... Because this will never do Session time out.. – Sachin May 17 '13 at 18:28