Yes, it has a cpanel, it only asks me to put the file name to run, and when to run it. Its quite simple, but I don't know if I need to run the code posted or a new code. Will the code know which user to put in the variable $userfinal? I don't know if it will work...
You will have to modify the code and maybe your database.
Pretty much you will need to use humbugs' solution.
In the cron file you will need to select all users that have not been active for lets say 10 minutes. Then run an update query for each user returned to set their status to 'offline'.
Last edited by kkeith29; Jul 20th, 2009 at 7:26 pm.
Sorry for not getting back to you about my idea. What I meant was, you store the timestamp for each user's last activity in the database. Then any time you want to check if someone is "active" you grab the timestamp and make the comparison.
You can also get a list of "active" user by doing (psuedocode) "SELECT * FROM user_activity WHERE timestamp>TIME()-60*5"
All you need to do for this is update the user's "last activity" timestamp every time they request a page, and you'll be laughing.
If you want it to be more accurate you can use AJAX to send a request to the server every 4 mins to tell the server that the user still has the webpage open in his/her browser.
Hope that helped. (I'm not saying the other way won't work either..)
For each user you want to check, you would do something like this:
1. Get the timestamp for this user from the database SELECT last_activity FROM user_activity WHERE id=$id 2. Compare this value with the timestamp for 5 mins ago within PHP if ($last_activity > $now-60*5) { echo "online" }
I couldn't be bothered looking up the PHP code for getting timestamps, or translating to and from MySQL timestamps, but you can do that
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.