-2

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?

1 Answers1

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