Jump to content

how to calculate Time Spent Online a user


fikiwan

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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...