So I’m trying to output a session’s variable value into a view (only if it exists). But I can’t seem to get it to work. No error. Nothing. What am I missing? Thought I had this down packed by now – guess not…
In controller…FYI, $data is assigned to the view (i.e. $this -> load -> view('view', $data);
$data['campaign_name'] = $this -> session -> userdata('campaign_name');
Here’s my php snippet in the view that I’m trying to output. So in short, if the session exists, output it. If not, do nothing.
<input type="text" name="campaign_name" class="wizardInput nameField" value="<? if (isset($campaign_name)) ;?> ">
Anyone?
EDIT Okay, I should have mentioned that i’m trying to output the session value into a FORM value. Modified view code above. The form submits as though the value is there – and even sends the value along. However, it’s not visible in the text input…
you can easly do this in your view:
then if you want to make session data as the value of an input do this:
you don’t need to control if session userdata exist cause if it not exist it doesn’t prints anything, cause
userdata()method returnsfalse!Then you don’t need to pass session data trough the
$data[] array, cause session data can be retrieved from anywhere (model/controllers/views/hooks/libraries/helpers and so on)