[eluser]bigtony[/eluser]
[quote author="nZac" date="1257736827"]My new questions is about using sessions... is this the right place for it? Should a session store a large HTML file?[/quote]
Sessions are used to retain state (i.e. data) across multiple pages. Two typical exampes are:
(1) You have a login page, where after the user enters a valid username & password you would a session variable like this (in your controller):
Code:
$this->session->set_userdata('logged_in', TRUE);
Then other pages in your site that should only be seen when the user is logged in can check the session field and allow/disallow depending on its value.
(2) You have a complex entry form which you decide to break up into two or more pages. Then you can store each pages responses as you go:
Code:
$this->session->set_userdata('name', $this->input->post('name'));
$this->session->set_userdata('address', $this->input->post('address'));
// etc.
Which lets you effectively assemble all the data together in the session so you can process at the final step (e.g. to store in a database).
Obviously lots of other uses, but it's definitely NOT intended for storing HTML files! That is what "views" are for. The data you need for a view is usually passed into it from a controller:
Code:
// This is in a controller
$view_data['name'] = 'Fred';
$this->load->view('mypage_view', $view_data);
Code:
// This is in the view 'mypage_view'
<h1>My Page Header</h1>
<p>My name is <?php echo $name; ?></p>
(The above example is not using sessions at all).