Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2003, 02:35 PM
Authorized User
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to natmaster Send a message via AIM to natmaster Send a message via MSN to natmaster
Default users online

i want to be able to count the number of users currently viewing my website, and the number of users currently logged in (i use sessions for my login script)

could someone point me in the right direction?

----------------------------
http://aeonofdarkness.com
__________________
----------------------------
Aeon of Darkness MUD - Free Online Roleplaying Game
http://aeonofdarkness.com
 
Old July 31st, 2003, 02:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Because PHP is a server side language, it's done processing as soon as the requested page is generated. It doesn't keep running on the client machine to check whether they're still active on the site.

If a user requests a page and promptly closes their browser, the server (read: PHP) is none the wiser.

The only way to track users on the server side, then, is to set a time threshold; for example: 15 minutes. Any user that requests a page is considered "logged in" for the next 15 minutes. If they don't request a page within 15 minutes of their previous request, they are considered "logged out".

If you're storing user activity in a database, you can simply select ALL the users who's last-active timestamp is less than 15 minutes from the current time.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting User registered and Users online motemape BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 May 25th, 2007 08:14 PM
users online vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 23rd, 2007 08:29 AM
users online.. ruhin Beginning PHP 0 February 9th, 2005 01:58 PM
Urgent ! Find Online Users qazi_nomi Classic ASP Databases 1 August 17th, 2004 04:39 PM
Counting users online via sessions richard.york Pro PHP 1 November 19th, 2003 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.