CodeIgniter Forums

Full Version: Not loading page due to session
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Gerep[/eluser]
Hi,

I have a session on my View with some data about files and every time I click the link to load this view it does nothing, its like I'm not clicking on the link but if I comment the line in the Controller that create the session and populate it, it works perfectly.

The session is been loaded and working and I know that because I have to login to get access to that View.

Piece of code
Code:
Controller

function list_files()
{
  $this->load->model('filesModel');
  $query = $this->filesModel->list_files();
  $this->session->userdata('files_list', $query);
}

Code:
Model

function list_files()
{
  return $this->db->query("SELECT * FROM files");
}

In the View I show the data like this:
Code:
foreach($this->session->userdata('files_list') as $files)
{
echo $files->name.'<br />';
}


When I comment the controller line
Code:
$this->session->userdata('files_list', $query);
or change it to
Code:
$this->session->userdata('files_list', 'test');
it works =(

Thanks in advance.

El Forum

[eluser]Bart Mebane[/eluser]
I think what you want is
Code:
$this->session->set_userdata('files_list', $query);

El Forum

[eluser]Gerep[/eluser]
OMG...such a stupid mistake...thanks a lot for your time and attention Bart, saved my day =)