使用Jquery加载时获取PHP会话ID

I've created a site that is using Jquery's load function as follows to reload only parts of the site without the user having to reload the whole site, for example.

$('#divtoreload').load('refresh.php');

This works great except for now I need the refresh script to show different info (pulled for a database) based on the users session id. However using the session_id(); function the session id doesn't seem to be pulled into the code so the database result returns nothing.

put session_start() on your refresh.php

Did you call session_start(); before you called session_id();? You must start the session in order to access any session variables.