Jump to content

how to calculate Time Spent Online a user

Recommended Posts

There's not a reliable way to do that. The basic idea would be to update your database every time they send a request to your site for any page. One way would be to periodically send ajax requests to update the timer in the database, so you maybe send an ajax request every minute or so to add another minute to the database. But obviously you can't tell if they have your site open in a browser but aren't actually using it, maybe they walked away for an hour. Sending ajax requests frequently will also cause their PHP session to never expire if you're using the session.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...