list of users that are logged on(sessions)
Moderator: General Moderators
list of users that are logged on(sessions)
Hello all,
I create a session variable (user name) for every user that is logging on to my system.
What I want to do is
1. To write a script that lists all of the users that are logging on
($_SESSION['user'])
I'm guessing that I can loop it somehow but I'm not sure how.
2. to destroy the session when the user is logged out.
any ideas?
I create a session variable (user name) for every user that is logging on to my system.
What I want to do is
1. To write a script that lists all of the users that are logging on
($_SESSION['user'])
I'm guessing that I can loop it somehow but I'm not sure how.
2. to destroy the session when the user is logged out.
any ideas?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Hi. Personally I dump the name of the user who has logged-in into a database along with the current time. When they are logged-in their record in the database (the time) gets updated.
I have a script that runs every ten minutes (automatically) which checks the times in the database. If someone has been unactive for more than ten minutes (or 15 max) then the script removes the users 'session' from the database and presumes the user has left the site.
I have a script that runs every ten minutes (automatically) which checks the times in the database. If someone has been unactive for more than ten minutes (or 15 max) then the script removes the users 'session' from the database and presumes the user has left the site.
Try http://www.evilwalrus.com/search.php?ca ... rch=online such snippets.
As far as the 'automatic' PHP code goes (the stuff that runs every 10 minutes or so) I'm not sure how that works as it's something the server has set-up. Basically I put PHP code into a page on the server and it gets run every 10 minutes, maybe someone else knows how to set this up?yaron wrote:Gen-ik,
Can yo post that script here?
I really want to get some ideas...
The theory behind the "if the user is logged in update a database with the current time" is pretty simple if you know how to use MySQL or MSQL and SESSIONS.
If you really get stuck though drop me an email and I'll send some stuff over to you.