Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP Members Logged In Count

Posted on 2009-05-13
7
Medium Priority
?
316 Views
Last Modified: 2012-05-06
Given that I have a working login function which verifies against a database, I would like a simple counter on my login page that shows:

Members Logged In : 9

Every time the login is successful, a global variable should be incremented. When the user logs out or the user's session dies, this global variable should decrement also.
0
Comment
Question by:fcqmax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
SPARC-DESIGN earned 1600 total points
ID: 24374410
hi there,
could this be usefull: http://www.sim-php.info/users-online-script.php
0
 
LVL 1

Assisted Solution

by:marty_t
marty_t earned 400 total points
ID: 24374580
Hi,

Best way, being as you're already programming with a DB, is to create a table within that DB for Login Sessions. This can simply have the Users ID in it with a timestamp that gets updated at each page view.

Every time it's updated, purge the data older than say 10 minutes, then count on the amount of rows you have. That will give you the amount of logged in users.

When a user logs out, it deletes them from the table.

Hope that helps.

Marty
0
 
LVL 3

Expert Comment

by:SPARC-DESIGN
ID: 24374606
@marty_t
If you would have clicked the link I posted, you wouldn't type all the text ;-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:marty_t
ID: 24374780
haha, too true
0
 

Author Comment

by:fcqmax
ID: 24375174
I understand the logic now, but what happens if a user just quits the browser without clicking the logout link to cleanly log out?
0
 
LVL 3

Expert Comment

by:SPARC-DESIGN
ID: 24375216
I understand the logic now, but what happens if a user just quits the browser without clicking the logout link to cleanly log out?
------
The session will die after a few minutes and the row will be deleted from the DB
0
 

Author Closing Comment

by:fcqmax
ID: 31581053
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question