thetwai Posted March 23, 2006 Share Posted March 23, 2006 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 meTW Quote Link to comment https://forums.phpfreaks.com/topic/5575-php-session/ Share on other sites More sharing options...
redbullmarky Posted March 23, 2006 Share Posted March 23, 2006 [!--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 meTW[/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. Quote Link to comment https://forums.phpfreaks.com/topic/5575-php-session/#findComment-19887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.