I have a PHP class object called Datapoints stored in session and I am trying to access a variable from it in a javascript function.
From within the javascript I can access session variables through $_SESSION['foo'], but I can't access the object variables. I've tried all sorts of syntax to return the variable.
I can access variables like this, and it works fine.
<?php echo intval($_SESSION['count']); ?>
but I would rather have the whole object in session, for example if I do this...
<?php
header("Content-Type: text/javascript");
session_start();
$c = $_SESSION['datapoints']->count;
$c1 = $datapoints->count;
?>
var count = <?php echo $c; ?>
var count1 = <?php echo $c1; ?>
Both return null.
My object looks like this through print_r('datapoints').
Datapoints Object ( [startdate] => 2013-06-05 [currency] => GBP [count] => 4527 [datapoints] => Array ( [0] => Datapoint Object (...) ... ))
Thanks
EDIT:
Thanks for your help, I've solved this now. Turns out it was a problem with the autoloader not loading classes properly from within the javascript files.