How Many Users Are On My Site Right Now?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

How Many Users Are On My Site Right Now?

Post by pando »

Hello
I have read this tutorial:
viewtopic.php?t=29342

I used the SESSION way.
I opened a new folder to keep the session_id logs, and it worked OK, beside that big problem.
the logs don't get deleted after I leave the site.

Is it beacuse I have changed the directory where the logs kept in, now I need to do the deleting all by myself?
How it can be done?

Thank you.




the code:

Code: Select all

<?php
session_save_path("/forum/session");
session_start();


$sessionfiles = session_save_path()."/sess_*";
$sessionarray = glob($sessionfiles);
$sessioncount = count($sessionarray);
?>
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I'd recommend using XHTML to determine this. I believe Burrito has a tutorial here detailing how to do it. It’s by far the most accurate way to determine how many users are on your site.
pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

Post by pando »

Well.. I'm new here.
I would ask Burrito excuse by I have no idea who the guy is. could you please give me a link to his tutorial?
Thanks.
pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

Post by pando »

found it
reading it
Thank you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the session system will run garbage collection at ~random intervals based on session.gc_probability and session.gc_divisor

http://php.net/session read the section on runtime configuration
pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

Post by pando »

no matter where the "garbage" is?

I have changed the path. would it still clean the garbage from the folder that in the new path?

3 people visited the page I'm working on
so I have 3 different session_id files in the new folder, they look like this one:
sess_417da72b6460593426590c583cfba71

time passes away... and they still there.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you had read how the two configuration values worked, you would know they determine when a garbage collection will happen cleaning up old session files...
pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

Post by pando »

"when" what about "where" ?
besides.. I have problem configure the lifetime of my SESSION, it seems that my server prevent me from changing the php configuration.

I don't have access to the php.ini on my server, so I tried use the .htaccess, I tried this line:

Code: Select all

php_value session.gc_maxlifetime "7200"
but it doesn't work.
so learning about the other 2 configuration might not be useful for me..
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

pando
Forum Newbie
Posts: 6
Joined: Sat Sep 17, 2005 1:06 pm

Post by pando »

Thanks
I will try it.
Post Reply