Hi, I am developing a CMS based website which also has a flash gallery, the gallery accepts only xml data as input so i am using info from a database to output the required xml using php.

I am setting the page that is currently being viewed using a session, i had then planned on using this session in the sql query to return only images that have been uploaded for that particualr page.

My problem is the session does not seem to be available to use in the xml page. I have used echo to check the value is stored on the page where the gallery is displayed, but on the page that outputs the xml there is nothing.

I then decided to create a test page which i used <?php echo $_SESSION; ?>
but again nothing was displayed.

Anyone got any ideas what i have done wrong?

Your test page must also have 'session_start()' at the top before any output. For compatibility with old versions of IE, you'll also want to add the P3P header.

index.php

<?php header('P3P CP="CAO PSA OUR"');
session_start();
$_SESSION['gallery'] = 42;
?>
<!DOCTYPE html>
<html>
<h1>Setting cookie!</h1>
<a href="/test.php">test</a><br>
<html>

test.php

<?php header('P3P CP="CAO PSA OUR"');
session_start();
$value = $_SESSION['gallery'];
?>
<!DOCTYPE html>
<html>
<h1>Getting cookie!</h1>
<? echo($value); ?>
<br>
<html>

Ahh ok didnt know you had to start the session again. Thanks very much

always put session_start(); at the top of your session