Online User Code

  • sase_95
  • Banned
  • Banned
  • User avatar
  • Posts: 17
  • Loc: Neg, MK

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

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.
  • hgun77
  • Graduate
  • Graduate
  • User avatar
  • Posts: 164
  • Loc: Malaysia

Post 3+ Months Ago

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.  

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 159 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.