Implementation of "Are you still there?" message

I would like to implement an Are you still there? prompt message with Yes and No options to prevent bandwith on my side as a provider.

I don’t want to be very aggressive and do it after 2 or 3 hours (like YouTube) of inactivity but, after e.g. 12 or 24 hours of inactivity I want there be a pop up message with yes and no options and on the server I will disconnect the user so no traffic is going to his computer until he asks for it again.

Then, if he clicks Yes after 30 or 40 hours - e.g. he was 2 days away from his running computer it will reconnect him.

What is the best strategy to do this? Has anybody done something like this?

Start a Javascript setTimeout on page load that redirects/shows the popup when it completes is the easiest and you don’t have to worry about managing state on your server.

If you want it to support across multiple sessions you could do a last_seen_timestamp field on the user and have your js call an endpoint that checks that value on some regular basis and pops up the message when it’s been long enough.