CodeIgniter Forums
Session Data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Session Data (/showthread.php?tid=24423)



Session Data - El Forum - 11-09-2009

[eluser]GamingFusion[/eluser]
I was wandering how i would get the membergroup data from ym database table into the session data.

I have looked at the Active record but haven't been able t find what i want. Here is what i have tried

Code:
<?php
$this->db->where('username', $this->input->post('username'));
            $database = $this->db->get('users');
            
            $data = array(
                'username' => $this->input->post('username'),
                'isLoggedIn' => true,
                'membergroup' => $database->result('membergroup')
                
            );
            
?>



Session Data - El Forum - 11-09-2009

[eluser]Thorpe Obazee[/eluser]
Did you really read the User Guide?


Session Data - El Forum - 11-09-2009

[eluser]InsiteFX[/eluser]
HINT: $this->session->user_data('item', 'value')

Enjoy
InsiteFX

P.S. As bargainph stated it's all in the user guide Session Library.


Session Data - El Forum - 11-10-2009

[eluser]GamingFusion[/eluser]
ok i got some where but now i for the membergroup is says array

Code:
<?php
$this->db->where('username', $this->input->post('username'));
            $database = $this->db->get('users');
            
            if ($database->num_rows() > 0)
            {
               $row = $database->row();
            
            $membergroup = $row->membergroup;
            
            }
            
            $data = array(
                'username' => $this->input->post('username'),
                'isLoggedIn' => true,
                'membergroup' => $database->result($membergroup)
                
            );
?>

I want it to get the row of the member that is logged in


Session Data - El Forum - 11-10-2009

[eluser]Mischievous[/eluser]
Code:
$query = "SELECT * FROM users WHERE username = '".$this->input->post('username')."'";
$result = $this->db->query($query);
$check = $result->num_rows();
            
if ($check > 0)
{
    $data = array(
        'username'     => $this->input->post('username'),
        'isLoggedIn'     => TRUE,
        'membergroup'     => $result->row('membergroup')
    );
    $this->session->set_userdata($data);
}


?? not sure what your askin


Session Data - El Forum - 11-10-2009

[eluser]GamingFusion[/eluser]
when i echo the membergroup is returns array still


Session Data - El Forum - 11-11-2009

[eluser]GamingFusion[/eluser]
does anyone know why it is returning "array" instead of what it should?


Session Data - El Forum - 11-11-2009

[eluser]GamingFusion[/eluser]
its working now