I have a PHP script used for AJAX queries, but I want them to be able to operate under the umbrella of Joomla\'s (2.5) framework so I can have session id\'s, user id\'s etc
This is absolutely possible by way of the Joomla Platform. The example I'll give you below is actually for J1.5, but is easily adaptable to J2.5 with some adjustment to the included files.
Another strong recommendation is to implement a ReSTful API instead of your custom scripts. It's outrageously simple using Luracast Restler. I had it up and running in about 10 minutes, then added the Joomla Framework as shown below, and had an extremely flexible Joomla based API using AJAX calls for my site in under an hour! Best spent development time in years, as far as I'm concerned.
yourscript.php
require_once('joomla_platform.php');
/* Get some of the available Joomla stuff */
$config = new JConfig();
$db = &JFactory::getDBO();
$user =& JFactory::getUser();
if($user->gid <25) {
die ("YOU CANT BE HERE");
}
echo "".print_r($config,true)."
";
joomla_platform.php