I have this project for school. There are three of us. I'm working on the "middle" (php/xml), while I have a partner working on the front end (ajax), and another partner on the back end (php/xml/mysql). I need to maintain a session for the front end accessing me, however it doesn't seem to work the same as when a user accesses the php file directly from the browser. Instead, he's doing something to make a request to my page with post variables, and I reply with xml. Similarly, I send a curl request to the back end and he replies in xml as well. So, I thought perhaps the browser somehow manages the session and sends a session id on every request. But since my page isn't accessed through a browser, but rather from the front end's page directly, perhaps this does not work. So, what I did was have him request a session id from me, and I'd start a session that way and reply with the id. Then, he'd send that sid for every request and I'd resume that specific session. Unfortunately, this does not seem to work. Here's the few lines of code that are relevant to this.
...
//start session if sid provided
if(isset($_POST['sid']))
{
session_id($_POST['sid']);
session_start();
}
if(isset($_POST['r']))
{
$req = $_POST['r'];
if($req == 'session')
{
//destroy old session if set
if(isset($_POST['sid']))
{
session_destroy();
}
//Starts a new session and replies with a session id
session_start();
$_SESSION['schedule'] = new Schedule();
$reply = session_id();
}
...