问题
I am creating a simple script say a.php. I know that drupal 6 creates a session etc. So in my a.php I am trying to print_r($_SESSION); but that doesnt seem to work. What is the best way to get the logged in users userid in my program?
Sorry I am new to drupal. Thank you for your time.
回答1:
Drupal's cron.php is a perfect example of a "simple" php script that uses the libraries in Drupal's /includes directory. The key lines in that file are:
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
if you include those in your own code, your a.php file will have access to all of Drupal's context and libraries.
来源:https://stackoverflow.com/questions/1056491/drupal-session-user-id-for-independent-script