0

I am asking a very basic question but I am feeling a great problem while managing sessions. Actually I have an requirement to show pop up,5 minutes before session expires that "Your session is going to expire in next 5 minutes" Press yes to continue and no to not.

Yes, Session time was 15 minutes earlier when everything was working fine. I have then changed the session timeout to 30 as per new requirements

like

 <sessionState timeout="30">
    </sessionState>

After 25 minutes, I show pop up to alert client that in next 5 minutes your session will be expired. So, following that pop up opens and alerts the client but what happens is session expired at 27th minute. I calculate it with time. I set the session variable when login is successful then It comes to the home page . The home page layout calculates the 25 minutes and then show pop up client side. Even if one thinks that it takes overhead after setting session and coming to home page and loading of script where I have defined function for pop up then also It should be the overhead of 20 seconds only as it comfortabley loads in 10 seconds. So, my problem is session expires before the set session time. That is session expired after 26 minutes and at start of 27th minute.

Why I am facing this issue is undetectable by me.If I have induced wrong logic , it's okay that should be a functionality default but session is not controlled by me. I set time out to 30 minutes, but it overs before this time. after exactly 26 minutes.

This is how I am measuring Time ::: myTimer() calls after 25 minutes and after 25 minutes this function shows pop up

myVar = setInterval(function () { myTimer() }, 1500000);

Sweetie
  • 1,298
  • 6
  • 24
  • 48
  • How are you measuring the time? You would need to use the server clock to measure this otherwise there would be a time difference – CodingIntrigue Mar 04 '14 at 08:14
  • I have updated the question.But sir if this is really to be the issue then Maximum difference there could be of 1 minute. But I am getting four minutes difference. – Sweetie Mar 04 '14 at 08:18
  • `setInterval` and `setTimeout` can be inaccurate. You should create a new `Date` object inside your `setInterval` callback: http://stackoverflow.com/questions/8173580/setinterval-timing-slowly-drifts-away-from-staying-accurate – CodingIntrigue Mar 04 '14 at 08:25

0 Answers0