Welcome Guest, Not a member yet? Register   Sign In
Reading Session Var in Heper
#1

[eluser]nk94555[/eluser]
Hi,

I am defining a session var in my controller and using a helper file in the view. I am not able to read the session var defined in controller using $this->session->userdata('item'); It errors that helper is not a class. Is there a way to do this instead of passing var to each helper function call from views.

Thanks,
Neeraj
#2

[eluser]pistolPete[/eluser]
What helper are you using?
#3

[eluser]TheFuzzy0ne[/eluser]
Can you give us an example of your controller (including top line and constructor), and your view file?
#4

[eluser]nk94555[/eluser]
In controller:
$this->session->set_flashdata('flow', 'web');
$this->load->view('quote_summary',$data);

In view:
$this->load->helper('my_app_ui');

I created a helper "my_app_ui".

Calling the following function from view:
echo printSumRow($firm_data,'email','Email');

function printSumRow($pData,$pField,$pLabel,$pLongText=FALSE)
{
$flow = $this->session->flashdata('flow');
.
.
}

Inside the printSumRow function in helper I don't have access to $this->session. I can read this in view. I don't want to pass this in each and every function call to "printSumRow", I thought session might do.

Thanks
#5

[eluser]pistolPete[/eluser]
Use something like that:
Code:
function printSumRow($pData,$pField,$pLabel,$pLongText=FALSE)
{
   $CI =& get_instance();
   $flow = $CI->session->flashdata('flow');

(...)
}




Theme © iAndrew 2016 - Forum software by © MyBB