CodeIgniter Forums
Not loading page due to session - 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: Not loading page due to session (/showthread.php?tid=37438)



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 =)