| | |
Logout after time
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Its best to check with help and support.
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
If your host has cpanel, you can do it from there easily.
Otherwise, check out some of the sites listed in the search.
http://www.google.com/#hl=en&q=cront...fp=Xmf0jJ9P_V0
Otherwise, check out some of the sites listed in the search.
http://www.google.com/#hl=en&q=cront...fp=Xmf0jJ9P_V0
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
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'.
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.
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
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..)
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..)
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
For each user you want to check, you would do something like this:
1. Get the timestamp for this user from the database
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
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
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
![]() |
Similar Threads
- how to get login and logout time of User..? (PHP)
- finding duration worked between time ranges from login and logout time (ColdFusion)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
ajax apache api array basics beginner binary broken cakephp checkbox class cms code codingproblem combobox cron curl database date display domain dynamic echo email error file files folder form format forms function functions google href htaccess html image include insert interactive ip java javascript joomla js limit link load login mail malfunctioning menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion reference remote return script search server sessions sms source space sql syntax system table tutorial unset up-to-date update upload url validation validator variable video web webapplications websitecontactform youtube







