Jump to content


Photo

Tracking the online users of a website


  • Please log in to reply
5 replies to this topic

#1 fiddy

fiddy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 13 October 2006 - 10:20 AM

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

#2 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 13 October 2006 - 10:45 AM

i use this on my site.

place this on top of your page

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

add user after logging onyour site

    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);
    }


Registered Linux User #399942
Ubuntu User #14134
--
my blog

#3 fiddy

fiddy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 13 October 2006 - 10:59 AM

Hi,

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

Thanks
Fiddy
:)

#4 fiddy

fiddy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 20 October 2006 - 05:33 AM

Thanks friends ..
:)

#5 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 06:59 AM

vbnullchar: Why not just use this query:
DELETE FROM forum_active_users WHERE u_timestamp='{$timeout}';
Then you wont end up with a lot of rows in that table.

#6 fiddy

fiddy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 20 October 2006 - 07:02 AM

Ok. Thanks for your guidence.
:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users