I have a page in Drupal from which I want to be able to read the $_SESSION data to determine the userid and their assigned role. As an exploration I attempted to print to the page the contents of $_SESSION so that I could see what was being stored and what the keys were to retrieve these values.
When I attempt to print to the page using
echo print_r($_SESSION);, instead of a set of reasonable session data, I instead get only this:
Array ( [batches] => Array (  => 1 ) )
I had a bit of a Google around to see if I was doing something wrong, and I came across the documentation for session.inc, which says:
These functions should not be called directly. Session data should instead be accessed via the $_SESSION superglobal.
So it seems that, while Drupal wants me to use $_SESSION to retrieve the session data, I can't do this because my $_SESSION data has only this odd pair of nested one-element arrays that store only the number 1.
I also came across some reports that not having the uid 0 in your users table can cause similar issues, so I have checked the users table and I do indeed have user 0.
Any ideas what is going wrong here?