Jump to content


Photo

PHP session


  • Please log in to reply
1 reply to this topic

#1 thetwai

thetwai
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 March 2006 - 09:50 AM

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

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 March 2006 - 10:04 AM

[!--quoteo(post=357532:date=Mar 23 2006, 09:50 AM:name=thetwai)--][div class=\'quotetop\']QUOTE(thetwai @ Mar 23 2006, 09:50 AM) View Post[/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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users