Drupal Session User id for independent script

2020-07-24 05:34发布

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.

标签: php drupal
1条回答
Animai°情兽
2楼-- · 2020-07-24 06:13

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.

查看更多
登录 后发表回答