This is a complicated problem, so I'm going to start by describing the problem. I don't think code samples are needed until someone has an idea of what could be the problem, so here goes...
I've built a PHP-based online course that uses custom session handlers to store sessions in MySQL. It seems to be working fine over both http and https connections. The course navigation works like this.
When a user logs in, my script determines what course they are taking, whether they're authorized, whether they need to take any prerequisites, etc. It then sends them to an index page, where their session is restored if they have already started the course, or it sets them up as a new user and initializes all the variables. Basically, we just pull the pages for the first chapter and set some $_SESSION arrays as follows:
$SESSION['pages_array'] - contains the unviewed pages for the chapter
$SESSION['current_page'] - contains the current page data
$_SESSION['pages_seen'] - contains the pages they've viewed.
So when a user clicks the "next" button, I simply push the current_page onto the pages_seen stack, then pop a new page off the end of the pages_array and set it to be the current_page and display it. To go "back" we do the exact opposite.
Once there are no more pages for the chapter, we try to grab the next chapter and if there's no pages left, the course is over.
Here's where it gets tricky. I also needed a Table of Contents page so I created a script that opens in a new window to list all the pages in the course and allow the user to click a page to navigate to. So if the user is on page 20 and they click to go t page 30, I have a function that simply pushes and pops pages from one stack to the other in my $_SESSION arrays, until we've reached the page. The logic is more complicated than that, but that's what's basically happening. This seems to work fine in most circumstances, but there's one circumstance where it seems to choke every time and show SOME but not ALL the wrong data for a page. This happens when I display a page that contains a dynamic FlashMX question which retrieves its question data from a database via a call to another PHP script. What's so strange is that no errors appear using normal naviagation which works the same way as my Table of Contents except it only moves one page at a time, whereas the TOC script moves multiple pages from one array to another in sequence. The TOC script calls a new page that shuffles the session arrays properly, then reloads itself and the parent window to display the new data for the current page. All the session manipulation should be happening in sequence. So, I know my scripts are being called consecutively and should not be trying to access session data simultaneously. But for some damn reason, if I go straight from one flash test page to another, I usually see the data for the previous flash test, but all the other data on the page is correct.
I originally thought this was a problem with Flash calling my PHP script and PHP returning messed up headers, but I cannot figure out why I'm getting the wrong data instead of no data at all if this is the case. So that makes me think it must be a session problem. How can I be getting some session data correctly and other session data incorrectly. I originally thought I only had a problem getting data into flash over my https connection (it didn't work at all) but as soon as I added an ob_start();ob_flush(); to the top of my script, the apparent header problem disappeared and the data began loading fine. But the current problem I'm having exists on both https and http connections so it's not an https problem. Has anyone else had problems with Flash getting the wrong data from PHP sessions?