I would like to indicate the particulars (from a MySQL database) of all those users that are currently on-line (those whom have successfully signed in). How should I go about achieving this? Does it have something to do with Sessions?
Jacques: the best solutions that I have seen involve session_set_save_handler: http://www.php.net/manual/en/function.session-set-save-handler.php
Yes you are correct. The basic idea here is: you create functions that will read / write / etc. session data into a database. The database you'll need is fairly simple (sess_id, data, timestamp).
Then once you have sessions stored in a database table you just do a count of the records in that table. It won't be 100% accurate (the accuracy depends on how long you let sessions go inactive before they get destroyed), but it's a clean and easy way to do it.
I suppose if you *really* wanted to you could do all of this through the filesystem session handler (counting files in that directory), but why would you when this job is already done so well with a database? :) Not only that, but moving sessions to a database has some other benefits... but that is another discussion for another day. :)
-- Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://www.php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
Attachment:
signature.asc
Description: OpenPGP digital signature