• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sessions in database - How to retrieve/deserialize user_data items

#10
[eluser]brianw1975[/eluser]
oh c'mon, I cannot be the only one who doesn't want to use a back-hoe to plant a flat of mums...

all the data needed is there:

Quote:string(86) “a:3:{s:11:“logged_user”;s:5:“michi”;s:7:“user_id”;s:1:“9”;s:8:“username”;s:5:“michi”;}”

serialized data can be read without decoding...

logged_user = "michi"
user_id = "9"
username = "michi"

get all of the currently active sessions and either deserialize it or regex the needed information out...

Code:
$query = "select * from {session data table} where last_activity > {5 minutes ago?}";
foreach($query->row as $u){
$info = deserialize($u);
if($info['user_id'] != {guest account id number})
   $logged_in_count++;
else
   $guest_count++;

$active_users[] = $info['username'];
}
$active_users = explode(', ',$active_users);

of course this is just off the top of my head and completely untested code, not to mention, not the only way to do the query either.


Messages In This Thread
Sessions in database - How to retrieve/deserialize user_data items - by El Forum - 09-19-2009, 07:34 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.