ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Session Variables
Posted by Frank on Aug-25-2010 08:58
I am struggling to create graphs using session variables. I want to have a html page that sets session variables with data and then have each of the images reference another PHP page that retreive the data from the session variables and creates the graphs. When I try to do this, I am getting the following error: "Cannot send session cache limiter - headers already sent".  I have put some sample code below to illustrate what I am doing.

Does anyone know what I am doing wrong or can point me to some code that works using session variables?

Thanks,
Frank (newbie to ChartDirector)
===============================
HTML PAGE
<?php
  session_start();
  $_SESSION['chart1data'] = 'dat';
  $_SESSION['chart2data'] = 'dat';
?>

<IMG SRC="http://www.xxxxx.com/chart1.php">
<IMG SRC="http://www.xxxxx.com/chart1.php">
=============================
CHART1 PAGE
<?php
session_start();
$data = $_SESSION['chart1data'];
.....
header("Content-type: image/png");
print($c->makeChart2(PNG));
=============================
CHART2 PAGE
<?php
session_start();
$data = $_SESSION['chart2data'];
.....
header("Content-type: image/png");
print($c->makeChart2(PNG));

  Re: Session Variables
Posted by Peter Kwan on Aug-25-2010 17:02
Hi Frank,

The error message is not related to ChartDirector. It is PHP error message, which means your code have output something before the session start up.

Note that you should not output anything before starting up the session (eg. before calling session_start if your session is not automatically start up using php.ini). I suspect the code in your message is not your real code, as it looks incomplete (eg. there is no <HTML> tag). The cause of the problem is probably in the code that you have not included in your message.

Make sure the <?php session_start(); ?> is the first line of code in your PHP file, starting from the first byte. There should not be anything before it (no HTML or other PHP code - not even an empty space or empty line). This ensures your code are not outputting anything before session start up.

Hope this can help.

Regards
Peter Kwan