table columns, last_login login_number
add to your php login script
update members set last_login=now() where user=$user
update members set login_number=login_number+1 where user=$user
code sample only, not checked, (laptop in public wifi, no notes)
once the timestamp is set then you can use php sql datetime functions to find any users who havent/haved in within any timespan
Or
create another table for visits keyed to the userid
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
the usual thing is a routine in the script that logs pages, keeps note of logged in users movements, that timesout other sessions if inactive for (preset time),
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
Logic:
1. Create a new field in your users table (fieldname: online)
2. Update the field with 1 if a user login and 0 if a user logged out
3. So you can come to know how many users are online and offline.
4. Check the process when a user login and logout.
I just give the suggestions.
rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
Is there a page which is called from all pages, some configuration or connection page. You may use that page to update user table. And I suggest to insert timestamp intead of flag.
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
the reply says it is not finished code,
it is a scrap of sql as a thought pattern, it would have to be properly setup in php mysql handling
the code that updates last_login login_count is_loggedin (and any other) should be in whichever file logs the user in, code for monitoring whether login is current has to be in EVERY page, so usually put it a menu include() file
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
Try your code with login and logout buttons.
rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
As almostbob suggested you may Use your menu file if you are having or any other file that is called in almost all pages to update user status.
I would prefer to do it in following way. I am not sure that it is the best way to do it or not. But it is just to start with.
1) create column in user master say last_accessed (datetime)
2) in you common file you may update user last_accessed column
suppose you store user name in session then you may write update query at the end of your file.
update usertable set last_accessed=current_timestamp() where userid='{$_SESSION['userid]}'
3) now you have time for each user in your usertable. now you may use this column for reporting, that depends on your requirements.
Are you getting?
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
following query will give the username with minutes(page accessed by user before that much minutes). You may set one standard say 20 minutes. If minutes is less than 20 minutes then he/she is online if minutes is greater than 20 then user is offline.
select userid, TIMESTAMPDIFF(minute,last_accessed,current_timestamp) login_since_minutes
from usertable
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270