I little while back I posted this question. I have updated that question with the AJAX script that worked for about 1 week. Basically I can use session_start()
from the AJAX script, and then I could access the session variables that I needed.
It is really strange, but I came in after the weekend, and this morning this script does not work anymore. It is very simple, here:
<?php
session_start();
$ajax_connection = mysql_connect('10.X.X.X',$_SESSION['username'],$_SESSION['password']);
$result_set = array();
while ($result_set[] = mysql_fetch_assoc($results)){
// do nothing
}
echo json_encode($results);
?>
Last week this worked flawlessly, and now in my error log i get the Undefined index: username
and Undefined index: password
warnings. And of course the MySQL connection is not established. So this script is not running the same session as the original connection. I used error_log(session_id())
to check the IDs of the parent page and the AJAX script, and sure enough they are different. When i reload the page and try every again, the IDs stay the same for the page and the AJAX script respectively, but they should be the same ID, not 2 different ones.
Anyway, does anyone have any idea why this wouldn't be working anymore, after working well for over a week?