Facebook Ajax输盘

I'm trying to develop a Facebook app but am hitting a problem with session variables. I call a script via ajax which sets a session variable. Later, I call a script via ajax which retrieves the previously set session variable, but the variable is empty.

The first script called when the app loads in index.php. I have the following at the top

<?php
session_start();
//Get PHP SDK
require_once 'facebook-php-sdk/src/facebook.php';
// Create our Application instance.
$facebook = new Facebook( array('appId' => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'cookie' => true, ));
$signed_request = $facebook -> getSignedRequest();
$like_status = $signed_request["page"]["liked"];
?>

The first script called via ajax sets the session variable like this:

$numbers = range(1, 52);
shuffle($numbers);
$_SESSION['cards'] = serialize($numbers);

The second script (which is called about 10 seconds later,so I don't think it will be a race problem) looks like this:

$numbers = unserialize($_SESSION['cards']);

The variable $numbers is empty even though no other script has emptied $_SESSION['cards'].

Should this work or am I doing it wrong? I'm very new to ajax. I've read there can be problems with ajax calls in an iframe which is the way the facebook app is set up but I haven't managed to find a resolution.

Anyone know how to fix this?

you must call session_start() on both index.php and ajax script to share same session