Re: [Phplib-users] Showing Who is Logged In
Brought to you by:
nhruby,
richardarcher
From: Andrew C. <ph...@ev...> - 2004-01-07 23:15:25
|
Okay, I guess it was less hassle than I thought. For the next person who stumbles into this, here is the code snippet to extract the uname from the session variables. I am using a custom "view sessions" page that uses templates and fits into my system so, there is a bit of abstraction. --------------------------------------- // Starting from the query to get the active sessions list $query = sprintf("select * from active_sessions where name = '%s' order by name asc, changed desc", $sess->name); $db->query($query); while($db->next_record()) { // decode the val field and pull out the username $decoded_val = base64_decode($db->f("val")); preg_match('/auth\[\'uname\'\] = \'(.+?)\'/', $decoded_val, $captured); $session_uname = $captured[1]; // $session_uname should now contain the uname for the session being listed // the rest of the display stuff goes here } --------------------------------------- If anyone has a better way to do this, let me know. Andrew Crawford ph...@ev... At 03:01 PM 1/7/2004 -0700, I wrote: >Well, after quite a bit of searching, I have been able to determine that >this is a frequently-asked question. I have found several references to >looking it up in the archives. However, I haven't been able to find a >straight answer in the archives. So, here it is: > >Is there a way to display a list of who is logged in? That is, can the >entries in the active_sessions table be associated with the related >entries in the auth_users (or auth_users_md5) table somehow? > >What I want is something like the view_sessions.php3 script in the phplib >distro but, that shows what user is associated with each session. Thus, >it should be easier to make a determination about who one is "kicking off" >when one manually destroys a session, who is engaged in specific system >activities, or who isn't logging out. > >I imagine it might be possible to decode the contents of >active_sessions.value and extract the necessary information >somehow. However, if someone already knows how this works and can explain >it (or even has working code to do it,) it would be a lot less hassle than >trying to reverse-engineer. > >Andrew Crawford >ph...@ev... |