I'm trying to build an array of tokens which are breadcrumbs for use with Amazon SimpleDB paged data. I am following your example of setting an associative array in a session. I have some code and it isn't working in that it breaks execution. $next page holds an integer and $token is a string. One of my questions is whether you really need to do a set vs. an add; of if an add on an unset array should work. And then below, am I messing up some syntax? I did figure out that the set isn't failing; it's setting something. I can't get any databack out; and from the print_r() I'm not sure if it's there are not since it's an object. I created a new page where I could try a simple test. The add method doesn't work when adding an array.
if(!isset($_SESSION['mediatoken'])) {
fSession::set(
'mediatoken',
array(
$nextpage => $token
));
} else {
fSession::add(
'mediatoken',
array(
$nextpage => $token
));
}
Here's a print_r
Array
(
[fSession::type] => normal
[fSession::expires] => 1312483684
[limit] => 25
[thispage] => 11
[mediatoken] => Array
(
[4] => CFSimpleXML Object
(
)
)
)
second test
<?
include_once('../inc/init.php');
$page = 1;
$token = 'token page 1';
fSession::set(
'mediatoken',
array(
$page => $token
));
$page = 2;
$token = 'token page 2';
fSession::add(
'mediatoken',
array(
$page => $token
));
// This will echo John
echo 'page 1 token:';
echo fSession::get('mediatoken[1]');
echo '<hr>';
echo 'page 2 token:';
echo fSession::get('mediatoken[2]');
?>