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

Session counting

P: n/a

Hello all,

There is system. Users are logging , working and logout.
Suppose, 5 users are working and Admin wants to find out no. of users
working on system with their name ?

How to find this ?

Thanks in advance.
Dec 18 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
pradeep wrote:
There is system. Users are logging , working and logout. Suppose, 5
users are working and Admin wants to find out no. of users working on
system with their name ?
Depends. Are you on a shared server? Are you using PHP's standard sessions?

If yes to both, then the answer is no! (Well, it could be done, but not
reliably.)

Best option is to write your own session handler -- i.e. the piece of code
which deals with saving and restoring session data -- easier than it
sounds! Store the session data in a database, and then you can simply use
a SQL COUNT(*) query to find the number of open sessions.

See: http://uk2.php.net/manual/en/functio...ve-handler.php

The comment from maria at junkies dot jp, dated 09/12/07 is a reasonably
good starting point.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 10 days, 21:16.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
Dec 18 '07 #2

P: n/a
pradeep wrote:
Hello all,

There is system. Users are logging , working and logout.
Suppose, 5 users are working and Admin wants to find out no. of users
working on system with their name ?

How to find this ?

Thanks in advance.
In addition to what Toby said, you can do it even on a shared host, but
neither is reliable. They work fine if the user logs off, but not if he
just shuts down his browser.

To do it without your own session handler, you need to keep a list of
logged-in people. Probably a flag in the database would be most
appropriate.

But you'll also need a timestamp field to tell when they did log in, and
if they've been logged in longer than the session time limit, you need
to clear the flag. Maybe easier would be just a timestamp - if it
exists, the person is logged in. When the person logs out, clear the
timestamp.

Then you need a program (i.e. a cron job) to go through the list on a
regular basis to clear users who have been logged in to long.

But none of this is very accurate. They really only tell you who logged
on - not whether they were still active.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.