I access it with $_SESSION['var'];
Here's a simple ajax chat I'm testing on the site which isn't receiving the session. Seems all pages called by ajax can't echo the session id.
chatroom.php
<?php
session_start();
include "header.php";
$sid = $_SESSION['sid'];
?>
<script src="chatroom.js"></script>
<p><textarea id="post"></textarea>
<input type="button" value="Send" onclick="sendMessage();"></p>
<div id="chatMessages"></div>
<script>
window.setInterval("refreshChat()",10000);
</script>
<body onload="refreshChat()">
and here is the chatpost.php file that inputs the chat message & user id (session id) into the db
<?php
session_start();
$date=time();
$q="INSERT INTO chatroom (posterid, post, timeposted) VALUES ('$sid', '$_POST[message]', '$date')";
mysql_query($q);
?>
Funny thing is, while just playing around with it right now I noticed that if all of the files are on the same home directory the session id gets sent. If I try to send the session from a file in the home directory to a file in another folder the session gets emptied. Any ideas why this is occurring? I'd very much like to keep my files organized as they are. xD