By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Check who is log in

P: n/a
Hi,

I need to write application which tell me
who is login. In example:
1. login as Shamrock
2. I see Shamrock login
3. someone login as Morbious
4. They both see : Shamrock & Morbious
5. Shamrock logout
6. Morbious refresh site and see only Morbious is logged
Any sugesstions ?
Best regards,

Shamrock
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I noticed that Message-ID: <42*********************@mamut2.aster.pl>
from Shamrock contained the following:
1. login as Shamrock
2. I see Shamrock login
3. someone login as Morbious
4. They both see : Shamrock & Morbious
5. Shamrock logout
6. Morbious refresh site and see only Morbious is logged
Any sugesstions ?


You need to store the login information in a file or database. Change
the database when someone logs out (or after n minutes of inactivity).
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
>I need to write application which tell me
who is login. In example:
1. login as Shamrock
2. I see Shamrock login
3. someone login as Morbious
4. They both see : Shamrock & Morbious
5. Shamrock logout
6. Morbious refresh site and see only Morbious is logged
Any sugesstions ?


Browsers don't log out. Users rarely log out (if you provide a
link to log out and the login is protecting sufficiently sensitive
information, a few of your users MIGHT use it).

The closest you can usually get is to (a) decide that a person is
logged out if the last page refresh is older than X time, and (b)
process explicit logouts if someone actually uses them.

Put the login info in a database. If they refresh a page, update
the last_refreshed_timestamp. To see who is logged in, select the
entries with a login name and whose last_refreshed_timestamp is
later than, say, an hour ago.

Gordon L. Burditt
Jul 17 '05 #3

P: n/a
Q: How to find the logged in users?
Q: How to find the number of logged in users?

A: If you use session based authentication/login mechanism, it is quite
easy when you use custom-DB-based session--so that the session
variables will be stored in database instead of default files. As the
session will be available in the database table, it is easy to query
it/count the number of sessions or records.

Refer:
http://www.php.net/session_set_save_handler
http://www.code.dearneighbor.com/db_esession.html

+++
@todo Cleanup. Better link to DB handler

Jul 17 '05 #4

P: n/a
"Shamrock" <Sh******@anywhatyou.want> wrote in message
news:42*********************@mamut2.aster.pl...
Hi,

I need to write application which tell me
who is login. In example:
1. login as Shamrock
2. I see Shamrock login
3. someone login as Morbious
4. They both see : Shamrock & Morbious
5. Shamrock logout
6. Morbious refresh site and see only Morbious is logged
Any sugesstions ?
Best regards,

Shamrock


A very simple way to do this is to glob the session save path, obtainable
through ini_get(). Session files have names of the form "sess_<session_id>".
Cut off the prefix and load each session by calling session_id(),
session_start(), and session_write_close(). Be sure to save a copy of the
current $_SESSION first.

The downside to this method is that on a share server, you will end up
reading the sessions of other web sites as well. There are ways to get
around the problem though.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.