1. Cara mengakses data user yang tersimpan ada tabel CI_SESSIONS
SOLUSI :
function active_users() {
$this->load->model('admin_model');
$query =$this->admin_model->get_active_users();
$num_row=$query->num_rows();
$result=$query->result(); $str="<br/><b>$num_row</b> Users are active at this time<br/>";
$str.="<table border=1 cellpadding=2><tr><td>User Name</td><td>User Role</td><td>IP Address</td><td>Last Activity</td></tr>";
foreach ($result as $row) {
$user_data=$row->user_data;
$final = array();
$str.="<tr>";
foreach (unserialize($user_data) as $k => $v) {
$final[] = array('key' => $k, 'value' => $v);
if($k=='username') {
$str.="<td>$v</td>";
}
if($k=='user_role') {
$str.="<td>$v</td>";
}
}
$str=$str."<td>$row->ip_address</td><td>".date('d/m/y : H:i:s',$row->last_activity)."</td></tr>";
}
$str=$str."</table>";
$data['users']=$str;
$this->load->view('admin_active_users',$data);
}
-- SELAMAT MENCOBA --
No comments:
Post a Comment