Jump to content

Archived

This topic is now archived and is closed to further replies.

thetwai

PHP session

Recommended Posts

I need to get how many session my server currently has?
Is there anyway to get the session count?

The problem is I want to know who is online on my site.
Please Help me

TW

Share this post


Link to post
Share on other sites
[!--quoteo(post=357532:date=Mar 23 2006, 09:50 AM:name=thetwai)--][div class=\'quotetop\']QUOTE(thetwai @ Mar 23 2006, 09:50 AM) [snapback]357532[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I need to get how many session my server currently has?
Is there anyway to get the session count?

The problem is I want to know who is online on my site.
Please Help me

TW
[/quote]

you COULD count the number of files in the session folder on your server, but you wouldnt really be able to determine who of your registered users is online.
to do that, you'd need to create a custom session handler. the code could drag on, but this will give you an idea how it works.
1, each page in your site should 'include' a sessions.php (or whatever you decide to call it) script, with the session handling functions.
2, the sessions.php file will update the 'last active' field in your mysql sessions table with the current time. also, it will automatically delete records from the table who's last activity was over a certain time. if the users session does not exist in the table, create it.
3, on your 'who is online' page, all you need to do is read and display all of the records from your sessions table.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.