CodeIgniter Forums
Not loading page due to session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Not loading page due to session (/thread-37438.html)



Not loading page due to session - El Forum - 01-10-2011

[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.


Not loading page due to session - El Forum - 01-10-2011

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



Not loading page due to session - El Forum - 01-10-2011

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