943,923 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 3513
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 19th, 2009
0

Re: Logout after time

I am using a free webhost and don't know if they have cron on it, is there a code to check it or should I just go to help and support?
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 19th, 2009
0

Re: Logout after time

Its best to check with help and support.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jul 20th, 2009
0

Re: Logout after time

Yes! It is available. I never noticed it before -_-

I don't know how to use it, is it possible for you to help me out a bit? Please and thank you.

EDIT:
Do I just run the code that was previously posted? I am guessing so...right?

-Toxikr3
Last edited by Toxikr3; Jul 20th, 2009 at 6:52 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 20th, 2009
0

Re: Logout after time

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
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jul 20th, 2009
0

Re: Logout after time

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...

-Toxikr3
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 20th, 2009
1

Re: Logout after time

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.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jul 20th, 2009
0

Re: Logout after time

Alright, I will try that, thank you.
-Toxikr3
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 21st, 2009
1

Re: Logout after time

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..)
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
Jul 21st, 2009
0

Re: Logout after time

Thanks! I was wondering about the comparison code
-Toxikr3
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 22nd, 2009
0

Re: Logout after time

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
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005

This thread is solved

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.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC