Welcome Guest, Not a member yet? Register   Sign In
Small issue with a Session?
#1

[eluser]Solarpitch[/eluser]
This is my first time using sessions in CI and I'm not sure whats happening. In another part of my application I'm assigning sessions as follows...

Code:
$this->session->set_userdata('13:00:00', 6)
$this->session->set_userdata('14:00:00', 26)
$this->session->set_userdata('15:00:00', 17)

The problem is when I try to call them in the showsummery chart below, they wont echo the value. I have echoed the sessions in another page and they print their respective values.



Code:
function showsummary()

{

$this->load->helper('graph');
$this->load->library('session');

//Strange thing is... if I was to set the session here, it would work fine...
$this->session->set_userdata('14:00:00', 26);

$chart =
"
<chart>
<chart_border color='000000' top_thickness='1' bottom_thickness='2' left_thickness='0' right_thickness='0' />
<chart_data>
<row>
<null/>
<string>6am</string>
<string>7</string>
<string>8</string>

<row>
<string>Region A</string>
//These will not print their values unless the sesion was set in this function like above
<number>".$this->session->userdata('14:00:00')."</number>
<number>".$this->session->userdata('15:00:00')."</number>
<number>".$this->session->userdata('16:00:00')."</number>
......            
</chart>
";

SendChartData ($chart);
}

Is there something I'm missing here?
#2

[eluser]Solarpitch[/eluser]
Let me just add to this... its been 4 hours and I could quite possibly be loosing my mind trying to figure this out.

I have confirmed that the sessions are being set correctly as I can print the values of them all over the application. However, when I called this chart function to print the values into the chart, the values print but are messed about.

eg:

CONROLLER...

Code:
function dashboard(){
    

$this->load->model('report_model');
$this->load->library('session');
        
$date = '20081209';

//set the hours to get reports
$hours = array(
array ("start" => '14:00:00', "finish" => '15:00:00'),
array ("start" => '15:00:00', "finish" => '16:00:00'),
array ("start" => '16:00:00', "finish" => '17:00:00')
);

//loop through the array and get the TOTAL for each hour
foreach($hours as $e)
{
$start = $e['start']; $finish = $e['finish'];
$hour_total = $this->report_model->hourly_breakdown($date, $start, $finish);

//store the hour start time and total for the hour in session
$this->session->set_userdata($start, $hour_total);

//the above session will hold now have...
//$this->session->userdata('14:00:00', '340');
//$this->session->userdata('15:00:00', '500');
//$this->session->userdata('16:00:00', '200');

}
        
$this->load->helper('graph');
$url = 'http://www.mysite.ie/enterprise/index.php/charter/show_report/';
$charturl = 'http://www.mysite.ie/enterprise/charts/charts.swf';
$chartlib = 'http://www.mysite.ie/enterprise/charts/charts_library';
        
$data['chart'] = InsertChart( $charturl, $chartlib, $url ,450,300,'cccccc' ); // passing the chart information to view.

$data['right_box'] = "right_box/dashboard_view";  
$this->load->view('template/page_1', $data);
}


//SO IN THE SHOW_REPORT FUNCTION BELOW....THIS IS WHAT HAPPENS

function showsummary()

{

$this->load->helper('graph');

$chart =
"


<chart>

<chart_data>
<row>

<string>14:00</string>
<string>15:00</string>
<string>16:00</string>

</row>

<row>

<string>Region A</string>
<number>".$this->session->userdata('14:00:00')."</number> //THIS WILL PRINT 500
<number>".$this->session->userdata('15:00:00')."</number> //THIS WILL PRINT 500
<number>".$this->session->userdata('16:00:00')."</number> //THIS WILL PRINT Noting

</row>

</chart_data>
</chart>
";

SendChartData ($chart);
}




Theme © iAndrew 2016 - Forum software by © MyBB