AJAX call failing when it encounters session_start()
Posted: Fri Jun 12, 2009 5:02 pm
My app uses an ajax call to get information from the database and return it as a string to be parsed in javascript and placed in the correct controls on the form. When the ajax call is invoked (button click) it returns a status 500(internal server error). My ajax script...
The script fails on session_start() and goes no further. I do not use session.auto_start in php.ini. The same code snippet works within the script that creates the page the ajax call is made from, see below.
My ajax code is fine because it is working when I call other scripts that are not looking for session data. I am only making 1 ajax call from the web page.
Who has an(the) answer?
Code: Select all
<?php
require_once('..\config.php');
session_start();
if (!isset($_SESSION['initiated']))
{
session_regenerate_id();
$_SESSION['initiated'] = true;
}
$bAjaxCall = true;
require_once('class.DataSource.inc.php');
...
?>
Code: Select all
<?php
// Require the configuration file before any php code.
require_once('config.php');
// * Execute the script
main();
function main()
{
session_start();
if (!isset($_SESSION['initiated']))
{
session_regenerate_id();
$_SESSION['initiated'] = true;
}
...
}
?>
Who has an(the) answer?