Reputation: 552
I am using Codeigniter's Session class to store session values in the database. Contained within the userdata
field is the user's username and other values.
I want to get the username
from each userdata
field where the lastactivity
is >= let's say 5 minutes.
The only way I can think to accomplish this is:
However this seems like the long way. Is there a cleaner/better way to do this?
Upvotes: 0
Views: 2584
Reputation: 1761
Try this code.
$query = $this->db->select('user_data')->get('ci_sessions');
$user = array(); /* array to store the user data we fetch */
foreach ($query->result() as $row)
{
$udata = unserialize($row->user_data);
/* put data in array using username as key */
$user[$udata['user_name']] = $udata['user_role'];
}
from the result array, u can fetch needed information.
Upvotes: 1