• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED]session question

#1
[eluser]the_unforgiven[/eluser]
i have set this in my controller:
Code:
if($query) // if the user's credentials validated...
{
    
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true,
'group_id' => 2  // But this line isn't right has the group_id is an INT(11)
);
$this->session->set_userdata($data);
redirect('/');
}
So what should the line look like as its not setting the session correctly in sessions table in user_data:
Code:
a:4:{s:9:"user_data";s:0:"";s:8:"username";s:8:"testuser";s:12:"is_logged_in";b:1;s:8:"group_id";i:2;}
And if i go into phpmyadmin i can change
Code:
group_id”;i:2;
to
Code:
group_id”;s:2;
which then works but need to know what the line commented above needs to be in order to do this on set_userdata.



SOLVED BY DOING THIS:
Code:
function home()
{
  if ($this->session->userdata('group_id') == '1') { // THIS LINE WORKS
  $data['ptitle'] = "Dashboard";
  $data['heading'] = "Welcome";
  $this->load->view('admin/home', $data);
  }else { redirect('admin/restricted'); }
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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