Jump to content

Archived

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

fiddy

Tracking the online users of a website

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]

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Hi,

Thanks for your help. Will this work if i close the window and login again instantly.

Thanks
Fiddy

Share this post


Link to post
Share on other sites
vbnullchar: Why not just use this query: [code]DELETE FROM forum_active_users WHERE u_timestamp='{$timeout}';[/code] Then you wont end up with a lot of rows in that table.

Share this post


Link to post
Share on other sites

×

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.