CodeIgniter Forums
Session with DB question (updated 11:15 CST) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Session with DB question (updated 11:15 CST) (/showthread.php?tid=40801)



Session with DB question (updated 11:15 CST) - El Forum - 04-19-2011

[eluser]R_Nelson[/eluser]
I am using sessions with the DB option what i would like to do is extend it so that it can be used to see what users are logged in.

Code:
$this->db->like('user_data','username');
$this->db->order_by('last_activity','desc');    
$data['query'] = $this->db->get('ci_sessions');

and when i log in the user_data looks like this
Code:
a:5:{s:8:"username";s:8:"britblad";s:2:"id";s:1:"1";s:4:"name";s:13:"Rodney Nelson";s:10:"user_level";s:2:"10";s:12:"is_logged_in";b:1;}

how do i display the info from this i want the username and the id to be useable i have a loop to display just not shure what to put in the loop it looks like this now
Code:
<?php foreach($query->result() as $row ): ?>
        
<?php endforeach; ?>



Session with DB question (updated 11:15 CST) - El Forum - 04-19-2011

[eluser]WanWizard[/eluser]
userdata is a serialized array, to convert it back to an array use unserialize().


Session with DB question (updated 11:15 CST) - El Forum - 04-19-2011

[eluser]R_Nelson[/eluser]
ok thx that fixes that problem