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!
Ok first i'll explain what i am trying to do and then how much i have working. I have a php page that prints out the username of each session online (username session var created once the user logs in). Just like a page to show who is online by reading the sessions currently in the specified folder on the server and printing out one of the session variables stored in each file. This works fine........until i add session_start() to the top of the php page and then it doesn't work at all. Here is the code that accesses the folder the sessions are stored in and prints of one of the variables:
This works fine no problem but when i add session_start() to the top of the php file it echo's nothing to the screen. Can someone tell me why this is happening and help find a way around this problem? Thanks.
I was not able to reproduce the error, although my spider senses tell me there is a better way to handle this.
Typically to count the number of logged in users, you have a lastactive column in the database that gets updated on every request, or via ajax polling (or both). Simply check whos been active within last x minutes.
If you are relying on the files, you might want to investigate how often your garbage cleanup occurs as well.