Online User Code

  • sase_95
  • Banned
  • Banned
  • User avatar
  • Joined: Aug 27, 2010
  • Posts: 17
  • Loc: Neg, MK
  • Status: Offline

Post August 30th, 2010, 12:43 pm

Hi everyone could anyone write a script that shows how many people are currently viewing a certan website!
I looked up on google but I just need a simple design!
Exp: Online users : 10online
I just need some script for the display of the total users online!!
Please can anyone help me???
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 30th, 2010, 12:43 pm

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post August 30th, 2010, 2:16 pm

The easiest way is to track each visitor to your website and log their IP and time of visit. Then you can count of the number of unquie visits in a certain time frame, say 60 minutes, to get your "online" users. When a visit time expires, older than 60 minutes, you can delete it from your log.

Using a database makes this really simple. If you dont have access to a database you can do the same thing with a flat file system.
#define NULL (::rand() % 2)
  • hgun77
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 29, 2005
  • Posts: 164
  • Loc: Malaysia
  • Status: Offline

Post September 17th, 2010, 9:32 pm

Database Schema
===============
(tblactivesession)
ip(PK)
timestamp

When user load the related page
PHP Code: [ Select ]
REPLACE INTO tblactivesession VALUES(USER_IP, time())
 
DELETE FROM tblactivesession
WHERE timestamp < time() - 10*60
 
  1. REPLACE INTO tblactivesession VALUES(USER_IP, time())
  2.  
  3. DELETE FROM tblactivesession
  4. WHERE timestamp < time() - 10*60
  5.  


Get ur user online count
PHP Code: [ Select ]
SELECT COUNT(*) FROM tblactivesession
 
  1. SELECT COUNT(*) FROM tblactivesession
  2.  
Malaysia > KL > TAR College

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 142 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.