The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 11:06:33 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: displaying live users...  (Read 1557 times)
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« on: April 28, 2009, 03:50:00 PM »

I am looking for a way to display 'current live users' on one of my online shopping carts.  I found a little php script that does it by recording ip address + timestamp in a textfile and then calculating people active in the last x amount of minutes.  It works fine on simple static pages, but when I have tried to integrate it into zencart framework I've only ran into trouble.  I don't want to keep mucking around with it...but another possibility occurred to me...the site is hosted on it's own VPS, couldn't I use netstat somehow to get that information?  only the threshold of 'use' may be different i suppose since netstat would be counting tcp connections.

Has anyone any suggestions or thoughts on this subject??


Logged

a ship is safe in the harbor, but that's not what it's for.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: April 28, 2009, 04:19:09 PM »

the temp/ directory is normally where sessions are stored. You *could* look at that directory and see how many files are there (it'd give you a pretty durn close number) - but if there are any other applications using sessions on a stored box you'll get their numbers as well. If I was you, I'd override the default session handling functions in PHP and keep sessions in my database. Then it's a simple query to see how many are currently active.

Actually, that is precisely what I do Wink I keep a siteID as well as sessionID in the table so that I can see how many are live for <x> site, how many are live on the box etc. I run a little cron job that flushes expired ones out - and when it does so it distills the information from (that) session into aggregates for the day and my master stats.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« Reply #2 on: April 28, 2009, 04:25:46 PM »

That sounds beautiful Perk, I'll have to look into it...I don't know very much about php sessions, i'll have to spend some time looking at it.  Thanks!

J
Logged

a ship is safe in the harbor, but that's not what it's for.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: April 28, 2009, 07:01:58 PM »

your cart is almost certainly using them Svakanda. almost certainly. You can most probably intercept the startup of the code for your whole app and rewrite the session handlers. Here's a thread that has code for mine.

Good luck!

http://www.perkiset.org/forum/php_code_repository_examples/perks_custom_session_handlers_using_a_database-t1458.0.html

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!