Jump to content

Tracking the online users of a website


fiddy

Recommended Posts

Hi,

I am looking for a way to track users who are logged in to my website. I thought of maintaining it in the DB and reset that DB entry when they logout. But, If the user go's out without logging out (by clicking the close button in the browser), it will show the status of the user as online always.

Expecting help related to this....

Thanks,
Fiddy.[color=black][/color]
Link to comment
https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/
Share on other sites

i use this on my site.

place this on top of your page

[code]  function remInActiveUsers() {
    $timeout = time()-(10*60);
    $query = "update members set mem_online=false, mem_session_id='' WHERE u_timestamp < '$timeout'";
    $this->query($query);
    }[/code]

add user after logging onyour site

[code]    function addActiveUsers($id){
    $time = time();
    $ip  = $_SERVER['REMOTE_ADDR'];
    $query = "INSERT INTO forum_active_users(u_userid, u_timestamp, u_ip) VALUES('$id','$time','$ip')";
    $this->query($query);
    }[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.