User Idle time

Can anyone think of a way to detect a user idle time in a browser?

I’m not talking about session.usertimeout.

I simply need to know how long the user is idle without affecting the session in anyway.

Reading session.usertimeout gives you the total default value for the user time out. It does not give you the amount of time left before the user actually times out.

Custom SDK control. How to detect idle time in JavaScript - Stack Overflow

Sesion variable that resets on every single event handler in your app?

Thanks Ivan!

Sigh. Yes that what I don’t want ot have to do.

Clearly Xojo is tracking the idle time in order to support session.timeout. I would just like a way to read that time.

1 Like

The web framework keeps track of this on the browser-side and only sends the event to the server when it’s time.

The problem is that what you’re asking for is to be able to ask for that info whenever, which would require updating it regularly, and thus send lots of events to the server. Basically,

  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • nothing changed
  • 30 seconds went by with no user input

As opposed to keeping track of it on the browser and then just sending the event at the end (which is what the framework does now).

  • 30 seconds went by with no user input

Just remember that every implemented event, however small, requires CPU cycles. If you were to implement this for every session all the time, the number of simultaneous sessions you could support per instance of your app would be severely diminished.

thanks, Greg.

Having thought through it, I am really only interested if the user is idle on the site itself. If they’re moving the mouse around and not clicking on anything, I quite frankly don’t care.

But if there is any interaction with the site, I can reset say. Session.user_idle_countdown_timer

Is there anyway to hook into the "top " of any incoming request? Some sort of a. Session.request_recived event?

The clicks are already coming to the server to handle regular business.

There isn’t, and trust me when I say that it’s not what you want. You’d catch every event, including things like timers that are running browser side as well as the heartbeat events that run to keep things in sync.

So you’re wanting to display a timer on the browser that tells users how long they’ve been idle? Im curious what the real-world use case is for that.

No.

We’re trying to measure the time spent by user on an individual customer file. But if the person gets up to go to the bathroom, we want a positive five minutes of idle time. But we do not wish to kill the session.

So… you could use the session timeout mechanism for this.

Set the timeout to something like 5 or 10 seconds and then if the event fires, add that amount to a counter and reset the timeout (I wouldn’t do anything lower than that just to keep your traffic down).